
Originally Posted by
pbaldy
How about
DoCmd.OpenForm "SecondFormName", , , "CustomerID Like '*" & Me.ControlName & "'"
Well i found a snippet of code that does get me started:
Code:
Private Sub Command6_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = Application.CurrentDb
Set qdf = db.QueryDefs("qrySelectProduct")
strSQL = "SELECT tblCustomerProduct.[Prod Code], tblCustomerProduct.[Prod Description] FROM tblCustomerProduct WHERE (((tblCustomerProduct.[Cust Code]) Like '*A003'));"
qdf.SQL = strSQL
DoCmd.OpenForm "frmSelectProduct"
End Sub
Now I have 2 problems:
1. Even though i got the button to change the criteria it is still inputted in the code. How would i retrieve the above "A003" automatically. That is the customer ID that coresponds to the customer next to the Command Button? It is also not present the form, but it is in the forms query.
2. How do I make this code work for all the buttons on the form?