dipique
04-25-2014, 01:59 PM
I have a form in a database that runs on a query. I would like to be able to limit what records appear on the form by setting query criteria based on parameters that I pass in code. But when I pass the parameter in VBA, the form still prompts for the query parameter. How can I make the parameter "stick"?
The code I use currently to set the parameter:
Private Sub Command0_Click()
'Set query parameter values
Dim qdf As DAO.QueryDef
'Set query parameter(s)
Set qdf = CurrentDb.QueryDefs("qryBricks")
With qdf
.Parameters("parColor") = "*" 'Usually this would be "Green" but I'm just trying to get the darn thing to run right now.
End With
'Launch form
DoCmd.OpenForm "frmBricks" 'At this point it asks me for the parameter even though I've already set it.
End Sub
Any help would be appreciated.
Thank you,
Dan
11609
The code I use currently to set the parameter:
Private Sub Command0_Click()
'Set query parameter values
Dim qdf As DAO.QueryDef
'Set query parameter(s)
Set qdf = CurrentDb.QueryDefs("qryBricks")
With qdf
.Parameters("parColor") = "*" 'Usually this would be "Green" but I'm just trying to get the darn thing to run right now.
End With
'Launch form
DoCmd.OpenForm "frmBricks" 'At this point it asks me for the parameter even though I've already set it.
End Sub
Any help would be appreciated.
Thank you,
Dan
11609