Since I don't know about writing codes I am using NorthWest Database for this part of the project. I saw a previous post and have been able to fix some. I still have problems. I have this part of the 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 Sales Reports Dialog form.
Dim strReportName As String
Dim strReportFilter As String
Dim lOrderCount As Long
' Determine report filtering
If Nz(Me.lstReportFilter) <> "" Then
strReportFilter = "([CustomerGroupingField] = """ & Me.lstReportFilter & """)"
End If
' Determine reporting time frame
Select Case Me.lstOrderPeriod
Case ByYear
strReportName = "Customer"
lOrderCount = DCountWrapper("*", "Order Analysis", "[Year]=" & Me.cbYear)
Case ByMonth
strReportName = "Customer"
lOrderCount = DCountWrapper("*", "Order Analysis", "[Year]=" & Me.cbYear & " AND [Month]=" & Me.cbMonth)
End Select
If lOrderCount > 0 Then
TempVars.Add "Group By", Me.lstOrderReports.Value
TempVars.Add "Display", DLookupStringWrapper("[Display]", "Customer Reports", "[Group By]='" & Nz(Me.lstOrderReports) & "'")
TempVars.Add "Year", Me.cbYear.Value
TempVars.Add "Month", Me.cbMonth.Value
eh.TryToCloseObject
DoCmd.OpenReport strReportName, ReportView, , strReportFilter, acWindowNormal
Else
MsgBoxOKOnly NoSalesInPeriod
End If
End Sub
But When I try to preview I get 2 errors i Compile error on eh.TryToCloseObject on this part of the error and The epression click you entered as the event produced variable not defined
tHANKS
' 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 Sales Reports Dialog form.
Dim strReportName As String
Dim strReportFilter As String
Dim lOrderCount As Long
' Determine report filtering
If Nz(Me.lstReportFilter) <> "" Then
strReportFilter = "([CustomerGroupingField] = """ & Me.lstReportFilter & """)"
End If
' Determine reporting time frame
Select Case Me.lstOrderPeriod
Case ByYear
strReportName = "Customer"
lOrderCount = DCountWrapper("*", "Order Analysis", "[Year]=" & Me.cbYear)
Case ByMonth
strReportName = "Customer"
lOrderCount = DCountWrapper("*", "Order Analysis", "[Year]=" & Me.cbYear & " AND [Month]=" & Me.cbMonth)
End Select
If lOrderCount > 0 Then
TempVars.Add "Group By", Me.lstOrderReports.Value
TempVars.Add "Display", DLookupStringWrapper("[Display]", "Customer Reports", "[Group By]='" & Nz(Me.lstOrderReports) & "'")
TempVars.Add "Year", Me.cbYear.Value
TempVars.Add "Month", Me.cbMonth.Value
eh.TryToCloseObject
DoCmd.OpenReport strReportName, ReportView, , strReportFilter, acWindowNormal
Else
MsgBoxOKOnly NoSalesInPeriod
End If
End Sub
But When I try to preview I get 2 errors i Compile error on eh.TryToCloseObject on this part of the error and The epression click you entered as the event produced variable not defined
tHANKS