the microsoft access database engine does not recognise "

thmsjlmnt3953

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

When i try to open my crosstab report i get the above error, the same dynamic report works fine in another db file however im stumped by this one, anyone able to help?
 
Hi,

Apologies for a lack of info, this is the code i use on my other db for my report but altered to suit this one..

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

Code:
    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
    
    

End Sub

Private Sub ReportFooter4_Print(Cancel As Integer, PrintCount As Integer)
    
    Dim intX As Integer

    '  Place column totals in text boxes in report footer.
    '  Start at column 2 (first text box with crosstab value).
    For intX = 2 To intColumnCount
        Me("Tot" + Format(intX)) = lngRgColumnTotal(intX)
    Next intX

    '  Place grand total in text box in report footer.
    Me("Tot" + Format(intColumnCount + 1)) = lngReportTotal

    '  Hide unused text boxes in report footer.
    For intX = intColumnCount + 2 To conTotalColumns
        Me("Tot" + Format(intX)).Visible = False
    Next intX
End Sub


Private Sub ReportHeader3_Format(Cancel As Integer, FormatCount As Integer)

    '  Move to first record in recordset at beginning of report
    '  or when report is restarted. (A report is restarted when
    '  you print a report from Print Preview window, or when you return
    '  to a previous page while previewing.)
    rstReport.MoveFirst

    'Initialize variables.
    InitVars

End Sub

Private Function xtabCnulls(varX As Variant)

    ' Test if a value is null.
    If IsNull(varX) Then
        ' If varX is null, set varX to 0.
        xtabCnulls = 0
    Else
        ' Otherwise, return varX.
        xtabCnulls = varX
    End If

End Function

the code breaks on the following part opening the report

Code:
    strDocName = "rptBarcodingMonthly"
    DoCmd.OpenReport strDocName, acViewReport

I have checked my report and nothing references the crosstab directly hence giving the error microsoft database engine doesnt recognise " as a valid field or expresion
 
OK - So suggest you read the link I provided and try to resolve it yourself first, then explain why this s not the solution. The message implies there is an issue with your report recordsource SQL.

The code you have provided does not make sense to me - what event triggers the first bit of code? and a number of objects are not 'declared (e.g. dbsReport) so how can I advise if potentially you have declared it elsewhere as some there type of object. Whilst the rest of the code implies the code is the report itself - so why are you opening it since it will already be open in order to run?
 

Users who are viewing this thread

Back
Top Bottom