Imdabaum
03-16-2010, 10:08 AM
Okay, I've seen some examples of where people automate parameters in a query
IE:
'First we'll set some variables:
Dim qdf As Querydef
Dim rst As Recordset
'then we'll open up the query:
Set qdf = CurrentDB.OpenQueryDef(qryName)
'Now we'll assign values to the query using the parameters option:
qdf.Parameters(0) = qryStartDate
qdf.Parameters(1) = qryEndDate
'Now we'll convert the querydef to a recordset and run it
Set rst = qdf.OpenRecordset
'Run some code on the recordset
'Close all objects
rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
What if I want to automate a report that uses a parameter query? Is there a way to do that? The report doesn't seem to have the parameter properties.
Background: I have one query that opens from a custom ribbon. The users enter the name of the person for which they want the report. Yesterday the boss told me I needed to have an individual report for all vendors that looks the same and can be emailed automatically. Rather than copy and paste 24 reports and 24 queries. I was hoping that I could just associate the report with the person it's being emailed to and iterate through the names for the report.
Anyone ever done something like this?
IE:
'First we'll set some variables:
Dim qdf As Querydef
Dim rst As Recordset
'then we'll open up the query:
Set qdf = CurrentDB.OpenQueryDef(qryName)
'Now we'll assign values to the query using the parameters option:
qdf.Parameters(0) = qryStartDate
qdf.Parameters(1) = qryEndDate
'Now we'll convert the querydef to a recordset and run it
Set rst = qdf.OpenRecordset
'Run some code on the recordset
'Close all objects
rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
What if I want to automate a report that uses a parameter query? Is there a way to do that? The report doesn't seem to have the parameter properties.
Background: I have one query that opens from a custom ribbon. The users enter the name of the person for which they want the report. Yesterday the boss told me I needed to have an individual report for all vendors that looks the same and can be emailed automatically. Rather than copy and paste 24 reports and 24 queries. I was hoping that I could just associate the report with the person it's being emailed to and iterate through the names for the report.
Anyone ever done something like this?