It looks pretty good.
A coople things to remember:
- In design view, the cmbProduct shoud have no recordsource. That will
leave it blank until you select a plan
- When building the select statement make sure each row has a space before
the quote. If you look at it in debug mode you will see why. It puts things
together and Access can't figure out what to do.
- First of all, the query looks like it is selecting plan information to set
the values in the products box. I assume you are trying to set products
because that is the box you assign the recordsource to at the bottom and the
code is in the plan afterupdate event.
- You also missed a space after the word from
- You said the table name was tblProduct, but you used ProductMnemonic in
the code
- Based on your query, you were selecting plans based on the product ID in
cmbProduct
I wrot the code the way I think it should look based on the what I think you
are trying to do. I am assuming you have a PlanID in the products table.
Private Sub cmbPlan_AfterUpdate()
Dim strSQL As String
If Nz(Me.cmbPlan, 0) <> 0 Then
strSQL = "Select ProductId ,ProductName "
strSQL = strSQL & "from tblProduct "
strSQL = strSQL & "where PlanId=" & Me.cmbPlan
With Me.cmbProduct
.RowSource = strSQL
.Requery
End With
End If
End Sub
Feel free to send me an email directly if you still need assistance. Keep
in mind, my email address has been altered. I think you can figure it out.