Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter query as sorce for Recordset 1

Status
Not open for further replies.

KLentsi

Programmer
Apr 27, 2001
4
US
Hi, there.

I’m trying to use Parameter query as source for Recordset. Parameter is actually reference to text box (ClientID) on a form. The procedure works fine with test constant parameter (1234) and generates error “Parameter missing. Expected Parameter1.”

Any ideas?
Thank you
 
Sorry, but I'm not sure what you mean by "The procedure works fine with test constant parameter (1234) and generates error “Parameter missing. Expected Parameter1.”"

Does it work fine or do you get an error?

The general rule to get this to work is to make sure that you don't close the form, just hide it, until you are done with the report.

Then the criteria for the query is something like:
=Forms!YourFormName!ClientID Kathryn


 
Sorry for misprint and thank you for quick advise.

Once again, when I enter "Forms!FormName!ClientID" I'm getting error. When I enter existing ClientID instead of reference to the text box, 1234 for example, the procedure works fine.

Thanks
Konstantin

 
OK, try this trick. When you are in the Query design view, instead of typing the Forms!... syntax, use the expression builder. Click in the Criteria box and go to the toolbar and choose the wand icon.

Navigate to the Forms folder, and choose your form (your form needs to be under Open Forms) and your control name. Make sure that the full name appears in the box before clicking OK.

That is what I do when I think I may have a syntax error. Kathryn


 
Make sure your form is open when the query is run. --------------
A little knowledge is a dangerous thing.
 
Thank you, guys,

Obviously the form is opened and syntax is correct. Moreover the query runs fine directly with reference to control as parameter.

The error is generated while running the code in which this query is used as source of recordset object.
 
OK are you using the Parameters object?

The code you are using should look something like this:

dim qdf as querydef
dim rst as recordset

set qdf = currentdb.querydefs("yourQueryName")
qdf.parameters![YourParameterPrompt] = Forms!....

set rst=qdf.openrecordset

If that is about what you have, why don't you post the code, and we'll see if we can see any errors. Kathryn


 
Thank you, Kathryne. I've got the idea. Now it works.
Konstantin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top