Suppressing Parameter Query Prompt

J

Jimbo

I'm trying to use a parameter query, but assign the values using VBA rather
than prompting the user.
I've tried assigning values to the parameter at run time using code such as:

CurrentDb.QueryDefs("qryMyQuery").Parameters("MyParameter").value = MyValue

I assign this query to a subform:

[sfmMySubform].SourceObject = "Query.qryMyQuery"

but it ignores the parameter values, and prompts the user for the parameters
anyway.

Another strange quirk about the subform right afer the SourceObject is
assigned -- it prompts for the parameter twice, not just once. It's running
the query twice? Hmmm.

The SQL statement of the query looks like:

SELECT MyField
FROM tblMyTable
WHERE (((MyField2)=[MyParameter]));

So, how do I stop the parameter prompts this way? If I go total SQL, I could
probably do it, but I thought there would be a better way.

... Jim..
 
D

Duane Hookom

Consider not using parameter prompts. Try reference a control on a form for
the criteria.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top