B
Bill R via AccessMonster.com
I'm using the following code:
Private Sub cmdRunRpts_Click()
Dim strSQL As String
Dim rsIPTs As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim recDt As Date
Dim i As Integer
strSQL = "SELECT IPT FROM tblIPTs WHERE sectid>1 ORDER BY IPT"
Set db = CurrentDb
Set rsIPTs = db.OpenRecordset(strSQL)
Set qdf = db.QueryDefs("qryNewIPTRpt")
qdf.Parameters(0).Value = CDate(Forms!frmDatePopUp.Form.Controls("txtDate"))
For i = 1 To rsIPTs.RecordCount
qdf.Parameters(1).Value = rsIPTs.Fields("IPT")
DoCmd.OpenReport "rptDailyIPTMtg", acViewNormal
If Not rsIPTs.EOF Then rsIPTs.MoveNext
Next i
End Sub
To run a series of reports from a command button on a popup form that has a
txtbox in which the user is to type a date. The date of each report,
Parameters(0), should remain the same. The "IPT" value will change for each
iteration of the report. As currently written, the code executes properly,
but the OpenReport command causes the parameter dialog to open again and ask
for the value that I hoped had been provided in the Parameters(0) line.
I would prefer not to concatenate the SQL string for the underlying query as
it has 4 lines of criteria in the criteria grid and about 15 fields. It just
doesn't seem like the best solution. The query works fine running the report
manually and it would be great if I could set these 2 paramaters in code.
Thanks,
Bill
Private Sub cmdRunRpts_Click()
Dim strSQL As String
Dim rsIPTs As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim recDt As Date
Dim i As Integer
strSQL = "SELECT IPT FROM tblIPTs WHERE sectid>1 ORDER BY IPT"
Set db = CurrentDb
Set rsIPTs = db.OpenRecordset(strSQL)
Set qdf = db.QueryDefs("qryNewIPTRpt")
qdf.Parameters(0).Value = CDate(Forms!frmDatePopUp.Form.Controls("txtDate"))
For i = 1 To rsIPTs.RecordCount
qdf.Parameters(1).Value = rsIPTs.Fields("IPT")
DoCmd.OpenReport "rptDailyIPTMtg", acViewNormal
If Not rsIPTs.EOF Then rsIPTs.MoveNext
Next i
End Sub
To run a series of reports from a command button on a popup form that has a
txtbox in which the user is to type a date. The date of each report,
Parameters(0), should remain the same. The "IPT" value will change for each
iteration of the report. As currently written, the code executes properly,
but the OpenReport command causes the parameter dialog to open again and ask
for the value that I hoped had been provided in the Parameters(0) line.
I would prefer not to concatenate the SQL string for the underlying query as
it has 4 lines of criteria in the criteria grid and about 15 fields. It just
doesn't seem like the best solution. The query works fine running the report
manually and it would be great if I could set these 2 paramaters in code.
Thanks,
Bill