I am new to access, I am creating a database and I am at the reports stage. I am using the Northwind sales dialog as it is close to what I want. I tried customizing the codes but my reports wont open.I am getting the 2501 code error. This is the code
Code:
Sub PrintReports(ReportView As AcView) ' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print View Reports Dialog form.
Dim strReportName As String
Dim lOrderCount As Long
' Determine reporting time frame
Select Case Me.lstImportPeriod
Case ByYear
strReportName = "Yearly Report"
lOrderCount = DCountWrapper("*", "Fuel Analysis", "[Year]=" & Me.cbYear)
Case ByQuarter
strReportName = "Quarterly Report"
lOrderCount = DCountWrapper("*", "Fuel Analysis", "[Year]=" & Me.cbYear & " AND [Quarter]=" & Me.cbQuarter)
Case ByMonth
strReportName = "Monthly Report"
lOrderCount = DCountWrapper("*", "Fuel Analysis", "[Year]=" & Me.cbYear & " AND [Month]=" & Me.cbMonth)
End Select
If lOrderCount > 0 Then
TempVars.Add "Group By", Me.lstImportPeriod.Value
TempVars.Add "Display", DLookupStringWrapper("[Display]", "View Reports", "[Group By]='" & Nz(Me.lstImportPeriod) & "'")
eh.TryToCloseObject
DoCmd.OpenReport strReportName, ReportView, , strReportFilter, acWindowNormal
Else
MsgBoxOKOnly NoImportsInPeriod
End If
End Sub
is there anyway I can make this code easier