3265 item not found error running VBA Code

thmsjlmnt3953

Registered User.
Local time
Today, 01:03
Joined
May 20, 2014
Messages
120
Hi,

I'm using the following code on_open of a report which works fine in another DB however when using it here i get the above error.

Code:
Private Sub Report_Open(Cancel As Integer)

    '  Create underlying recordset for report using criteria entered in
    '  EmployeeSalesDialogBox form.
    
    Dim intX As Integer
    Dim qdf As QueryDef
    Dim frm As Form
            
    '   Don't open report if EmployeeSalesDialogBox form isn't loaded.
    'If Not (IsLoaded("EmployeeSalesDialogBox")) Then
    '    Cancel = True
    '    MsgBox "To preview or print this report, you must open " _
    '    & "EmployeeSalesDialogBox in Form view.", vbExclamation, _
    '    "Must Open Dialog Box"
    '    Exit Sub
    'End If

    '  Set database variable to current database.
    Set dbsReport = CurrentDb
    Set frm = Forms!frmnavigation!NavigationSubform.Form
    
    
    
    '  Open QueryDef object.
   '   Set qdf = dbsReport.QueryDefs("EmployeeSales")
    
      Set qdf = dbsReport.QueryDefs(Me.RecordSource)
    
    
    ' Set parameters for query based on values entered
    ' in EmployeeSalesDialogBox form.
    qdf.Parameters("Forms!frmnavigation!NavigationSubform!BeginningDate") _
        = frm!beginningdate
    qdf.Parameters("Forms!frmnavigation!NavigationSubform!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

I've also attached an image of the query and parameters set up for this.

query.jpg


any help would be fantastic.
 
It matters what line the error occurs on. :)
 
Hi,

Thanks for your reply i was just about to mark this as solved as i had set the recordset wrongly in the report :)
However im having another issue with this loading the report now

Code:
strDocName = "rptBarcodingMonthly"
    MsgBox strDocName
    DoCmd.OpenReport strDocName, acViewPreview

msgbox is only in there to ensure strdocname was being set properly

im getting the error

The Microsoft Access database engine does not recognize " as a valid field name or expression. (Error 3070)


ive checked my query parameters etc and they seem fine?
 
try to open the report out of code first.
 

Users who are viewing this thread

Back
Top Bottom