Help to load a query to a report?

T

TA

Hello all your guys,
I know your guy can help me fingure this out!
Here my situation : I created a report but not base on a
query. Whenever the user click on print a report I open a
report like this:
DoCmd.OpenReport "Rep2001_ind", acViewPreview
How can I load a query to this report?
Becase I want just create 1 report but it can print out
different year (base on the form user select from the list
box 1999-2005)
Thanks you in advance,
TA
 
G

Gary Miller

TA,

You better watch out! There a lot of very sharp gals here as
well.

If the user is selecting the year from a form, you should
bind the report to a query that is general enough for
everything and then use the 'Where' clause of the OpenReport
command to specify that you want it to open to the year that
the user selected. You haven't supplied any field names or
data types to work with, but here is the general concept if
year is a text string both on the form and the report
query...

Dim strSQL as String

strSQL = "[Year] = '" & Me!lstYear & "'"

DoCmd.OpenReport "Rep2001_ind", acViewPreview,, strSQL

Gary Miller
Sisters, OR
 
T

TA

Thanks Gary,
I wil try do that now.
Best Regards,
TA
-----Original Message-----
TA,

You better watch out! There a lot of very sharp gals here as
well.

If the user is selecting the year from a form, you should
bind the report to a query that is general enough for
everything and then use the 'Where' clause of the OpenReport
command to specify that you want it to open to the year that
the user selected. You haven't supplied any field names or
data types to work with, but here is the general concept if
year is a text string both on the form and the report
query...

Dim strSQL as String

strSQL = "[Year] = '" & Me!lstYear & "'"

DoCmd.OpenReport "Rep2001_ind", acViewPreview,, strSQL

Gary Miller
Sisters, OR

Hello all your guys,
I know your guy can help me fingure this out!
Here my situation : I created a report but not base on a
query. Whenever the user click on print a report I open a
report like this:
DoCmd.OpenReport "Rep2001_ind", acViewPreview
How can I load a query to this report?
Becase I want just create 1 report but it can print out
different year (base on the form user select from the list
box 1999-2005)
Thanks you in advance,
TA


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top