Combo Box Problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MikoKitty
    New Member
    • Nov 2006
    • 12

    #1

    Combo Box Problems

    I'm trying to populate a combo box using the following code:

    Code:
        Do Until rs.EOF
            strComVal = rs!clnt_LastName
            cbxSearch.AddItem (strComVal)
            rs.MoveNext
        Loop
    My problem is when it hits .EOF rather than exiting the Loop it tries to go through and throws an error NO current record. Why won't it stop?
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by MikoKitty
    I'm trying to populate a combo box using the following code:

    Code:
        Do Until rs.EOF
            strComVal = rs!clnt_LastName
            cbxSearch.AddItem (strComVal)
            rs.MoveNext
        Loop
    My problem is when it hits .EOF rather than exiting the Loop it tries to go through and throws an error NO current record. Why won't it stop?


    Try this

    while rs.EOF=false
    strComVal = rs!clnt_LastNam e
    cbxSearch.AddIt em (strComVal)
    rs.MoveNext
    wend

    Comment

    • hariharanmca
      Top Contributor
      • Dec 2006
      • 1977

      #3
      Originally posted by MikoKitty
      I'm trying to populate a combo box using the following code:

      Code:
          Do Until rs.EOF
              strComVal = rs!clnt_LastName
              cbxSearch.AddItem (strComVal)
              rs.MoveNext
          Loop
      My problem is when it hits .EOF rather than exiting the Loop it tries to go through and throws an error NO current record. Why won't it stop?

      Why you are not specifying any index value for any item it’s not so important but anyway it’s better to avoid one more query to fetch the index of each item.

      Comment

      • MikoKitty
        New Member
        • Nov 2006
        • 12

        #4
        Originally posted by hariharanmca
        Try this

        while rs.EOF=false
        strComVal = rs!clnt_LastNam e
        cbxSearch.AddIt em (strComVal)
        rs.MoveNext
        wend
        Tried that and got the same error as the original code. I [i]did[i] get it to work using
        Code:
        intRecNum = rs.RecordCount - 1
        For intCnt = 0 To intRecNum
                            strComVal = rs!clnt_LastName & "," & rs!clnt_FirstName
                            cbxSearch.AddItem (strComVal)
                            rs.MoveNext
        Next
        Thanks for trying

        Comment

        • hariharanmca
          Top Contributor
          • Dec 2006
          • 1977

          #5
          Originally posted by MikoKitty
          Tried that and got the same error as the original code. I [i]did[i] get it to work using
          Code:
          intRecNum = rs.RecordCount - 1
          For intCnt = 0 To intRecNum
                              strComVal = rs!clnt_LastName & "," & rs!clnt_FirstName
                              cbxSearch.AddItem (strComVal)
                              rs.MoveNext
          Next
          Thanks for trying
          what error you are geting exactly

          Comment

          Working...