Coding Question: Combo Box

mdr0906

Registered User.
Local time
Today, 18:45
Joined
Oct 9, 2007
Messages
15
Hello,

I am new to VB programming and need help with writing a SQL query statement. I am creating a database with a Microsoft template, and I would like to incorporate interactive combo boxes. For instance, if I were to select a particular supplier in the combo box in the main form, then the combo box in the subform would only show products that the supplier offers. I found that I need VB programming in order to do so and currently use the following code:

Private Sub SupplierName_AfterUpdate()
Dim sSQL As String

'Build the SQL query statement
sSQL = "SELECT ProductID, ProductName " & _
" FROM Products " & _
" WHERE SupplierID = " & Me.SupplierID.Value & ";"

'Set the row source property of combo productname
Me.ProductName.RowSource = sSQL
'Refresh the form data
Me.ProductName.Requery


End Sub

What is the proper code to use for subforms?

Thanks for your help.
 
Thanks

This is good resource. Thanks:)
 

Users who are viewing this thread

Back
Top Bottom