Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2012

    Unanswered: code isn't working

    I have this code
    Sub PrintReports(ReportView As String)
    ' 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.
    On Error GoTo ErrorInThisFunction
    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
    strReportName = "Customer Order Report"
    Select Case Me.lstOrderPeriod
    Case ByYear
    lOrderCount = DCountWrapper("*", "Order Analysis", "[Year]=" & Me.cbYear)
    Case ByMonth
    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

    DoCmd.OpenReport strReportName, ReportView, , strReportFilter, acWindowNormal

    End If
    ExitPrintReports: 'Exit function if no error
    Exit Sub
    ErrorInThisFunction: 'Print the error and error number so you can search
    MsgBox "Error " & Err.Number & ", " & Err.Description

    End Sub

    Private Sub cmdPreview_Click()
    PrintReports acViewReport
    End Sub
    but nothing happens when I click on the printpreview button

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    its possibel the code isn't executing
    make certain the form 'knows' about the code behind control.
    in the forms design mode right click the relevant control
    select code builder that should switch to code veiw and force the association between the control and the code that runs

    if that doesn't work put a breakpoint on cmdPreview and step through the code
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2012
    going to try
    Would not have been able to complete that database without this forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts