njellis
IS-IT--Management
- Jul 17, 2006
- 29
I have a query (qryHTMLOutput) that I need to pre-set a criteria on a single item (Phone1). I have a button and when I click that button, I want it to set the criteria based on what's on the form (i.e. me.phone1)
I can't seem to figure out how to do this.
I have tried this: but I think it only works on "action queries"
I can't seem to figure out how to do this.
I have tried this: but I think it only works on "action queries"
Code:
Private Sub testEvent_Click()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryHTMLOutput")
'Set the value of the QueryDef's parameter
qdf.Parameters("Phone1").Value = Me.Phone1
'Execute the query
qdf.Execute dbFailOnError
'Clean up
qdf.Close
Set qdf = Nothing
Set dbs = Nothing
End Sub