Why not simply store the year in a local table and include that table in your queries?
Also using a text value as a year isn't very efficient, you'd be better off storing it as a date and simply extracting the year portion in your queries.
i do understand, may be i don't know how to do it. What iam trying to do is Use a Single Query and a Report for Different forms. Iam able to open a Query with DoCmd.OpenQuery but DoCmd.OpenReport gives and unknown error.
if the form (frmReports) is open, and the combo box is filled, then the query should work.
are all these true?
and there are no spaces in around the asterisk in the criteria: "*"
if the query works, then the report aint far behind.
1. Like is used ONLY with strings
2. Like is used ONLY when you want to search for partial strings.
3. It doesn't make sense to use Like with a field that contains a Year in any case.
4. You CANNOT pass operands to a query so you couldn't pass this string into a query.
Your query should use a tempvar as Gasman suggested. Each form would populate the tempvar at some appropriate point. Then the query uses the = operand to compare to the tempvar.
Select ...
From ...
Where Somefield = yourtempvar;
I don't care for tempvars so I am not up on the syntax. That might have to be: