R
Rohit Thomas
Hello all,
I am trying to create reports on the fly based on criteria
that a user selects using several combo boxes on a dialog
box. I tried to follow the methodology used in the sample
Developer Solutions database however, I'm getting the
following error when the code runs: Run-time error "3265",
Item not found in this collection.
Here is the code that I modified from the Developer
Solutions database to suit my needs:
Option Compare Database
Option Explicit
Dim dbsReport As Database
Dim rstReport As Recordset
Private Sub Report_Open(Cancel As Integer)
Dim qdf As QueryDef
Dim frm As Form
Set dbsReport = CurrentDb
Set frm = Forms!frmPrintPreviewReports
Set qdf = dbsReport.QueryDef("qryBank001TellerFifty&Under")
qdf.Parameters("Forms!frmPrintPreviewReports!CmbDate") _
= frm!CmbDate
qdf.Parameters("Forms!frmPrintPreviewReports!CmbTeller") _
= frm!CmbTeller
qdf.Parameters("Forms!frmPrintPreviewReports!
CmbErrorcode") _
= frm!CmbErrorcode
Set rstReport = qdf.OpenRecordset()
End Sub
I am new to VB and do not fully understand how to use the
QueryDef method. Any insight as to what I'm doing wrong
would be very helpful.
Thanks,
Rohit Thomas
I am trying to create reports on the fly based on criteria
that a user selects using several combo boxes on a dialog
box. I tried to follow the methodology used in the sample
Developer Solutions database however, I'm getting the
following error when the code runs: Run-time error "3265",
Item not found in this collection.
Here is the code that I modified from the Developer
Solutions database to suit my needs:
Option Compare Database
Option Explicit
Dim dbsReport As Database
Dim rstReport As Recordset
Private Sub Report_Open(Cancel As Integer)
Dim qdf As QueryDef
Dim frm As Form
Set dbsReport = CurrentDb
Set frm = Forms!frmPrintPreviewReports
Set qdf = dbsReport.QueryDef("qryBank001TellerFifty&Under")
qdf.Parameters("Forms!frmPrintPreviewReports!CmbDate") _
= frm!CmbDate
qdf.Parameters("Forms!frmPrintPreviewReports!CmbTeller") _
= frm!CmbTeller
qdf.Parameters("Forms!frmPrintPreviewReports!
CmbErrorcode") _
= frm!CmbErrorcode
Set rstReport = qdf.OpenRecordset()
End Sub
I am new to VB and do not fully understand how to use the
QueryDef method. Any insight as to what I'm doing wrong
would be very helpful.
Thanks,
Rohit Thomas