Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Report using SQL Query Held in Variable

Status
Not open for further replies.

MrTBC

Technical User
Nov 19, 2003
610
US
Access 2003
Hi there.
I have a Command Button that generates an SQL Query as a String Variable and then sets this as the Row Source for a List Box.
So far so good.
I then have a second Command Button that Opens a Report. How can I code this second Button so that it passes the SQL Query to the Report and it becomes the Reports Data Source?

Many Thanks.
 
Have a look at the 3rd argument of the DoCmd.OpenReport method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you. I assume I need to extract the WHERE portion of the SQL query from the end of the word WHERE onwards?
 
You confuse the 3rd and the 4th arguments.
Try this:
DoCmd.OpenReport "yourReportName", acViewPreview, yourGeneratedSQLstring

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ah yes, that's working perfectly now.
Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top