Hi,
I have created a dynamic query with the code below. This works fine for one record in a subform. But how can I execute the code for all the records in the subform? Imagine, if I have two records in the subform, one with function A and one with function B, how can I combine these in one query? Thank you for the help.
Kind regards,
Code:
Private Sub cmd_ButtonClick()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Query")
strSQL = "SELECT TABLE.FUNCTION " & _
"FROM TABLE " & _
"WHERE TABLE.FUNCTION='" & Me.FORM.Controls!ASS_FUNCTION.Value & "';"
qdf.SQL = strSQL
DoCmd.OpenQuery "Query"
Set qdf = Nothing
Set db = Nothing
End Sub