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.
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.