Results 1 to 4 of 4

Thread: Combo Boxes Problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    17

    Question Combo Boxes Problem

    Hello guys ...

    I have a combination of 3 combo boxes.
    The first one is cboComFrom where will list all the company id.
    The second one is cboComTo where when the user select any data from cboComFrom, the rest of the data will appear here.

    example:

    data in cboComFrom : 1,2,3,4,5,6
    user select : 3

    cboComTo will appear: 3,4,5,6

    I already got this one..but the problem is when dealing with third combo boxes, cboEmpNo.The combo boxes here will appear all the relate employee no base on selected company id in cboComTo. But donno why the it doesnt work.

    code:

    Private Sub cboComFrom_Click()
    Dim index As Integer
    'cboComTo.Clear

    'to get the employee number base on selected company id

    If chkStatus(index).Value = 0 Then

    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '0' Order By ComID"

    End If

    If chkStatus(index).Value = 1 Then

    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '1' Order By ComID"

    End If

    If chkStatus(index).Value = 2 Then

    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '2' Order By ComID"

    End If

    If chkStatus(index).Value = 3 Then

    strSQL = "Select EmpNo From Emp00Curr Order By ComID"

    End If


    'intstatus = xPutSessionID(intSessionIDEC)
    RecordOption = 1
    intstatus = XQLFetch(intCursorIDEC, RecordOption, Len(Emp00CurrSQL), Emp00CurrSQL, 1, 1, 0)


    Dim i As Integer
    ' Loop through list of item in cboComFrom
    ' from selected item through end of list

    Screen.MousePointer = vbHourglass

    For i = cboComFrom.ListIndex To cboComFrom.ListCount - 1
    ' Copy item from cboComFrom to cboComTo
    cboComTo.AddItem cboComFrom.List(i)

    Do While intstatus = 0
    'put the data into the combo box
    With cboEmpFrom

    .AddItem (Trim(Emp00CurrSQL.EmpNo))

    End With

    RecordOption = 2
    intstatus = XQLFetch(intCursorIDEC, RecordOption, Len(Emp00CurrSQL), Emp00CurrSQL, 1, 1, 0)

    Loop

    Next
    ' If cboComTo contains items...
    If cboComTo.ListCount Then
    ' Select first item
    cboComTo.ListIndex = 0
    End If


    Screen.MousePointer = vbNormal

    End Sub

    anyone who can detect the error plz help me....i am using pervasive sql as my database

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    VB Code:
    1. select case chkStatus(index).Value
    2.     case else
    3.         strSQL = "Select EmpNo From Emp00Curr Where Recsts = " & chkStatus(index).Value & " Order By ComID"
    4.     case 3
    5.         strSQL = "Select EmpNo From Emp00Curr Order By ComID"
    6. End Select

    You are filtering on a number - no need to surround it with anything.
    Text is usually surrounded by single quotes (')
    Dates are usually surrounded by hash (#)

    Try the above code to simplify what you have, or at least remove the single quotes

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    17
    okay...actually there was a mistake in my code. I cannot use the chkStatus(index) cox i didnt declare the index

    i already fixed it like dis:

    Private Sub cboComFrom_Click()

    cboComTo.Clear
    Dim i As Integer
    ' Loop through list of item in cboComFrom
    ' from selected item through end of list

    For i = cboComFrom.ListIndex To cboComFrom.ListCount - 1
    ' Copy item from cboComFrom to cboComTo
    cboComTo.AddItem cboComFrom.List(i)

    If chkStatus(0).Value = vbChecked Then
    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '0' Order By ComID"
    End If

    If chkStatus(1).Value = vbChecked Then
    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '1' Order By ComID"
    End If

    If chkStatus(2).Value = vbChecked Then
    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '0' Order By ComID"
    End If

    If chkStatus(3).Value = vbChecked Then
    strSQL = "Select EmpNo From Emp00Curr Where Recsts = '1' Order By ComID"
    End If


    RecordOption = 1
    intstatus = XQLFetch(intCursorIDEC, RecordOption, Len(Emp00CurrSQL), Emp00CurrSQL, 1, 1, 0)

    Do While intstatus = 0
    'put the data into the combo box
    With cboEmpFrom

    Screen.MousePointer = vbHourglass
    .AddItem (Trim(Emp00CurrSQL.EmpNo))

    End With

    RecordOption = 2
    intstatus = XQLFetch(intCursorIDEC, RecordOption, Len(Emp00CurrSQL), Emp00CurrSQL, 1, 1, 0)

    Loop

    Screen.MousePointer = vbNormal
    Next

    ' If cboComTo contains items...
    If cboComTo.ListCount Then
    ' Select first item
    cboComTo.ListIndex = 0
    End If


    End Sub

    But yet, it still cannot work.....the employee number still wont come out.....I am using the pervasive SQL...i didnt really familiar with dis but have to use it...I dont know why it doesnt appear but it does enter the loop and read the code add item. but yet still no data appear in cboEmpNo. Im very sure that the data are exist in the table

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Code:
    "Select EmpNo From Emp00Curr Where Recsts = '0' Order By ComID"
    The bit in red should be 0. No single quotes (see previous post).


    Also, when posting vb code up surround it in
    [vb code] [/vb code](no space in the middle of vb code) an

    For other code forget the vb bit so you get [co de][/co de] (again without spaces)

    It reformats the view nicer.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width