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

Reply

Join Date: May 2009
Posts: 5
Reputation: monurenjith is an unknown quantity at this point 
Solved Threads: 0
monurenjith monurenjith is offline Offline
Newbie Poster

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

 
0
  #1
May 18th, 2009
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..........
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,086
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 125
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

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

 
0
  #2
May 18th, 2009
If the values are being populated from database, better handle all that using SQL queries.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 805
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 146
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

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

 
0
  #3
May 18th, 2009
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
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz

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

 
0
  #4
May 23rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

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

 
0
  #5
May 25th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC