|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Access Programming Question
Howdy y'all,
A friend of mine enlisted my help for programming a database she's using for her senior project. One little problem, though: it's an Access DB and I don't know VB, nor do I have the time to learn the ins and outs. I would appreciate a little code snippet/example of how to do the following: I have two combobox controls on a form: Combo1 and Combo2. Combo1 contains category information (e.g., Home, Garden, Tools, ...) Combo2 contains item information based on what is selected in Combo1. My question: How do you code the OnChange event for Combo1 to grab the selected value in Combo1, construct a SQL query to grab the necessary items, and then populate Combo2 with the new items? Thanks for any help,
__________________
Jon Sagara "Me fail English? That's unpossible!" |
|
#2
|
||||
|
||||
|
Well, I haven't worked with VB in ages, and I'm not certain what method you're using to access the DB (I'm assuming ADODB in my example), but I hope this helps:
Code:
Dim sText As String
Dim sSQL As String
Dim rs as ADODB.Recordset
sText = Combo1.Text
sSQL = "SELECT foo FROM bar WHERE baz = " & sText
' Run your SQL statement here
Combo2.Clear
rs.Open sSQL
While not rs.EOF
Combo2.AddItem (rs("FieldName"))
rs.MoveNext
Wend
rs.Close
|
|
#3
|
||||
|
||||
|
Thanks Scorpion.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Access Programming Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|