Passing values to a report

ilanray

Member
Local time
Today, 06:37
Joined
Jan 3, 2023
Messages
129
Hi
I have a form with 2 links to the same report. I would like to pass a value regarding each link and use the query on the report the filter for example:
At form called x i have 2 buttons. each click open report called Y ( i use the on click event and use docmd.openreport .....) . the only different in the query is the where clause.
I thoght of using something like
Sass:
select *
from tbl
where iif(passingValue =1 , "xxxxx",yyyyy)
any idea?

Thanks,
 
use the where parameter of the openreport command
 
can you give me an example?
 
Let's use a better query example:

Q1 = select * from tbl where [Field1]='X'
Q2 = select * from tbl where [Field2]='Y'

What you do is make a generic query without any criteria:

Q3 = select * from tbl

You base your report on it, then you use DoCmd.OpenReport to apply the criteria in that manner:

DoCmd.OpenReport "YourReport", acViewPreview, , "[Field1] = 'X'"
DoCmd.OpenReport "YourReport", acViewPreview, , "[Field2] = 'Y'"
 

Users who are viewing this thread

Back
Top Bottom