View Full Version : Passing a parameter to a query


tinker
08-23-2001, 02:09 AM
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

Chris RR
08-23-2001, 04:34 AM
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.