943,771 Members | Top Members by Rank

Ad:
May 18th, 2009
0

Vbcombobox problem...........

Expand Post »
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..........
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
monurenjith is offline Offline
5 posts
since May 2009
May 18th, 2009
0

Re: Vbcombobox problem...........

If the values are being populated from database, better handle all that using SQL queries.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
May 18th, 2009
0

Re: Vbcombobox problem...........

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...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub ComboCountry_Click()
  2. SQL = "SELECT tblState.State, FROM tblState INNER JOIN tblCountry.iCountryID = tblState.iCountryID WHERE tblCountry.vCountry = '" & comboCountry.Text & "'"
  3. '....execute query, loop through RS to populate comboState...
  4. End Sub

Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
May 23rd, 2009
0

Re: Vbcombobox problem...........

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. 'dim strings and integers where possible. Don't use actual references.
  3. Dim strMyCountry, strCountryBox. strCombo
  4. Dim intX as integer
  5.  
  6. For intX = 0 To cmbCountry.ListCount -1
  7. strMyCountry=myrs!country
  8. strCountryBox=cmbCountry.List(intX)
  9. strCombo=cmbCountry.List(intX)
  10. If UCase$(strMyCountry) = UCase$(strCombo) Then
  11. cmbCountry.text=cmbCountry.List(cmbCountry.List(intX))
  12. Exit For
  13. End If
  14. Next
Last edited by Jupiter 2; May 23rd, 2009 at 9:36 am. Reason: Brackets for Code Tags
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
May 25th, 2009
0

Re: Vbcombobox problem...........

in what line did the error occured?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. For intX = 0 To cmbCountry.ListCount - 1
  2. If UCase$(myrs!country) = UCase$(cmbCountry.List(intX)) Then
  3. cmbCountry.ListIndex = intX
  4. Exit For
  5. End If
  6. 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).
Last edited by jireh; May 25th, 2009 at 5:38 am.
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to determine when command button is clicked
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: how to overwrite a text file without the prompt





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC