I think that Docmd.RunCommand acCmdQueryParameters will simply open the
Query Parameters dialog box during the design view of a query. I don't
think that this is your intention. I think that you would like to run a
query, and pass a value to the existing parameter within the query.
If so, then...
The following code sample is brought you by...
Total Visual Sourcebook
http://www.fmsinc.com/products/sourcebook/index.html
Function RunQueryParameter(strQuery As String, strParameter As String,
varValue As Variant, _
Optional ByRef rlngRecAff As Long) As Boolean
' Comments : Run an Action query that requires a parameter
' Parameters: strQuery - a saved ACTION query to run
' strParameter - name of parameter to specify
' varValue - the value to assign the parameter
' Returns : True if successful, False otherwise
' Revisions : 11/15/99 - SBC, DJH - Modified to work with ADO
If gcfHandleErrors Then On Error GoTo Proc_Err
Dim cmd As ADODB.Command
Dim cat As New ADOX.Catalog
'Open the Catalog to be able to see the stored Queries
cat.ActiveConnection = Application.CurrentProject.Connection
'Set the Command Object to the desired Query
Set cmd = cat.Procedures(strQuery).Command
'Set the Parameter value. Don't forget the brackets!
'cmd.Parameters("[" & strParameter & "]") = varValue
'Run the query
'Because there is only one parameter, send with the execute method
cmd.Execute rlngRecAff, varValue
RunQueryParameter = True
Proc_Exit:
Exit Function
Proc_Err:
Call ErrHandler(mcstrModName, gstrProcName)
RunQueryParameter = False
Resume Proc_Exit
End Function