Help to load a query to a report?

  • Thread starter Thread starter TA
  • Start date Start date
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
 
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
 
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


.
 
Back
Top