Run Time Error 3265

J

Jennie

I created a dialog box which prompts for criteria for a report. In Access 97,
I copied the code from the Developer Solutions sample database, everything
worked (so far anyway) with the exception of this code:

Private Sub Report_Open(Cancel As Integer)

' Create underlying recordset for report using criteria entered in
' RunReportByDate form.

Dim intX As Integer
Dim qdf As QueryDef
Dim frm As Form

' Don't open report if RunReportByDate form isn't loaded.
If Not (IsLoaded("RunReportByDate")) Then
Cancel = True
MsgBox "To preview or print this report, you must open " _
& "RunReportByDate in Form view.", vbExclamation, _
"Must Open Dialog Box"
Exit Sub
End If

' Set database variable to current database.
Set dbsReport = CurrentDb
Set frm = Forms!RunReportByDate
' Open QueryDef object.
Set qdf = dbsReport.QueryDefs("Cites")
qdf.Parameters("Forms!RunReportByDate!BeginningDate") _
= frm!BeginningDate
qdf.Parameters("Forms!RunReportByDate!EndingDate") _
= frm!EndingDate

' Open Recordset object.
Set rstReport = qdf.OpenRecordset()

' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstReport.Fields.Count


End Sub

I keep getting a Run-Time Error 3265 - Item not found in this collection for
this statement - Set qdf = dbsReport.QueryDefs("Cites"). Anyone know what is
going on?
 
J

Jennie

Thanks, I got passed that error, now I am getting the same message for the
next statement. This is killing me.
 
W

Wayne Morgan

Set frm = Forms!RunReportByDate
' Open QueryDef object.
Set qdf = dbsReport.QueryDefs("Cites")
qdf.Parameters("Forms!RunReportByDate!BeginningDate") _
= frm!BeginningDate

Well, the next line is the first of two Parameters lines. It is looking for
a parameter in the query you just set in qdf. The parameter in the query is
called "Forms!RunReportByDate!BeginningDate" and the value this parameter is
being set to is "frm!BeginningDate". Open the query in design view, is there
a parameter with the name listed above? If so, on the form listed in the
"Set frm=" line, is there a field or control called "BeginningDate"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top