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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use VBA to control query statement

Status
Not open for further replies.

seca650

Technical User
Dec 4, 2002
14
CA
I have one report layout that I want use to produce two reports (documents). Each report will require a different SQL statement. I know how to setup a checkbox on a form to tell which statement to run.

What is the syntax to represent the select query.

As a secondary step I need to be able to run a make-table query to obtain an extraction of the previously generated report, for archiving purposes. Now, on the close event of the report, I run the make-table query. I should be able to create an SQL statement for this as well.

What is the syntax to represent the make-table query.

There is more, but I will leave it at this for the moment.
 
Hi,
You don't really need to create SQL statements for this. You can create the queries using the query painter, and then call it from your VBA code using the following code:
DoCmd.OpenQuery qryDocuments1

In fact, you don't even need to run the query, because your report can use the query as its' recordsource. If you need to pass some criteria to the query, I wrote an FAQ on this topic: faq703-2696 HTH, [pc2]
Randy Smith
California Teachers Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top