Need Help; QueeryDef Method?

woodchuckwood

Registered User.
Local time
Today, 18:13
Joined
Jan 15, 2004
Messages
10
Why wont this work?
----------------------------------------------
Private Sub Command5_Click()


Dim MyDb As Database
Dim qdf As QueryDef
Dim strSQL As String
Dim Rst As Recordset

Set MyDb = CurrentDb()


strSQL = "SELECT ReportGenerator.RptDesignName FROM ReportGenerator WHERE (((ReportGenerator.Region)=[Forms]![SelectRegion]![RegionList]));"

Set Rst = qdf.OpenRecordset


Do While Not Rst.EOF

Debug.Print qdf!RptDesignName

Rst.MoveNext

Loop

End Sub
------------------------------------------

I get the error at the "Set Rst = qdf.OpenRecordset" portion of the script.

I basically want to excecute the SQL statement because it will help generate the specific reports by the selected region. (I did not include the report generation code).



:confused:
 
The SQL string is doing nothing. You haven't set the name of a querydef to the querydef object. What do you intend to do with the recordset once it is open? Opening the recordset outside of the report doesn't do anything for you.
 
Thanks for the info Pat.


What i intended to do with the sql statement is to query the reportgenerator table to display what reports are specifed by a chosen region(via list box in a form)

Then i want to take the selected reports(pulled from the query)
and generate them to a folder on C:

I thought the QueryDef method could get me closer to my goal.

I posted my initial attempt to solve this problem by hardcoding all of the tables into an index....it can do the job but not well.

It seems so easy in theory but I'm pulling my hair out trying to figure it out.
 

Users who are viewing this thread

Back
Top Bottom