Passing a parameter to a query

tinker

Registered User.
Local time
Today, 07:29
Joined
Aug 20, 2001
Messages
25
Hiya
Im still having difficulties querying a query depending on the value selected. Ive done a bit of experimenting.

The sample program consists of a table, querie and a form.

In the table i have one field with several page sizes in it e.g "5*4", "A4" etc.

The query is based on the one field of the table with a Where contition of SQL3.

In the form i basically have a command button with code as follows

Dim sql3 As Variant
sql3 = "5*4"
stDocName = "Query1"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Thanks in Advance
 
I'm sure that there are cooler ways to do this, but I would put a new field on the form to hold the value that you are currently storing in SQL3. I'd set the visible property for this field to no and the locked property to yes. Then you should be able to pick up the value from the form in your query.

Hint: Whenever I've got these invisible fields on a form, I set the background to red and the text to yellow (or some other particularly obvious and obnoxious combo). Then when I look at the form in design view, I immediately know that this is not a field that I meant for the user to see.
 

Users who are viewing this thread

Back
Top Bottom