Hello,
I have a form (called MyParentForm) with a subform (called MySubForm). On MyParentForm I have a text field called "txtState" and a command button called "cmdFind". The subform is based on a query I call here "MyQuery". When I fill in a state in the text field and click on the command button I want my subform to be filled with the records containing that state.
Now, here is the code that I've put in the click-event of the command button:
Private Sub cmdFind_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")
strSQL = "SELECT [MyTable].* FROM [MyTable] WHERE [MyTable].State = '" & txtState & "';"
qdf.SQL = strSQL
End Sub
So far the code. Now, what do I have to put after the code qdf.SQL = strSQL to let the command button look up all the records containing the State choosen in the text field on my parent form?
Thanks in advance.
I have a form (called MyParentForm) with a subform (called MySubForm). On MyParentForm I have a text field called "txtState" and a command button called "cmdFind". The subform is based on a query I call here "MyQuery". When I fill in a state in the text field and click on the command button I want my subform to be filled with the records containing that state.
Now, here is the code that I've put in the click-event of the command button:
Private Sub cmdFind_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")
strSQL = "SELECT [MyTable].* FROM [MyTable] WHERE [MyTable].State = '" & txtState & "';"
qdf.SQL = strSQL
End Sub
So far the code. Now, what do I have to put after the code qdf.SQL = strSQL to let the command button look up all the records containing the State choosen in the text field on my parent form?
Thanks in advance.