I HAVE USED THREE COMBO BOXES IN AN APPLICATION
COUNTRYCOMBO,STATECOMBO,DISTRICT COMBO . THESE CONTAINS THE ITEMS FROM A TABLE .COUNTRY COMBO IS FILLED IN THE FORM LOAD EVENT. STATE COMBO IS FILLED IN THE CLICK EVENT OF COUNTRY COMBO . DISTRICT COMBO IS FILLED IN THE CLICK EVENT OF STATE COMBO . STYLE PROPERT OF THE COMBO BOX IS 2. BUT WHEN I'M RETRIEVING THE VALUES FROM THE TABLE TO THE COMBOBOX RUNTIME ERROR 91 OCCURS.
<CODE> For intX = 0 To cmbCountry.ListCount - 1

If UCase$(myrs!country) = UCase$(cmbCountry.List(intX)) Then
cmbCountry.ListIndex = intX
Exit For
End If
Next </CODE>
PLS HELP ME .......... THNKS IN ADVANCE..........

If the values are being populated from database, better handle all that using SQL queries.

Yeah, if your looking for a specific unique identifier based upon the text of the combo box that the user selected and your database has been normalized and you have defined the relational fields then...

Private Sub ComboCountry_Click()
SQL = "SELECT tblState.State, FROM tblState INNER JOIN tblCountry.iCountryID = tblState.iCountryID WHERE tblCountry.vCountry = '" & comboCountry.Text & "'"
'....execute query, loop through RS to populate comboState...
End Sub

Good Luck

'dim strings and integers where possible.  Don't use actual references.
Dim strMyCountry, strCountryBox. strCombo
Dim intX as integer

For intX = 0 To cmbCountry.ListCount -1
strMyCountry=myrs!country
strCountryBox=cmbCountry.List(intX)
strCombo=cmbCountry.List(intX)
If UCase$(strMyCountry) = UCase$(strCombo) Then
cmbCountry.text=cmbCountry.List(cmbCountry.List(intX))
Exit For
End If
Next

in what line did the error occured?

For intX = 0 To cmbCountry.ListCount - 1
      If UCase$(myrs!country) = UCase$(cmbCountry.List(intX)) Then
            cmbCountry.ListIndex = intX
            Exit For
      End If
Next

Does the error occurs here? cmbCountry.List(intX). Sorry I have no VB4/5/6 here... Is it List or Item? like cmbCountry.Item(intX).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.