Search code examples
ms-accessvbams-access-2007

VBA code is printing report instead of opening it


I have a button on a form that should open a report but it sending the report to the default printer instead. How do stop it from printing? I'm using access 2010

Private Sub Generate_Click()
    If Me.Staff = "<< All >>" Then
        DoCmd.OpenReport "rptAll", acViewNormal, , , acHidden
    Else
        DoCmd.OpenReport "rptStaff", acViewNormal, , , acHidden
    End If
End Sub

Solution

  • You should use acViewReport as stated here in the MSDN doc if you want to show the report.

    http://msdn.microsoft.com/en-us/library/office/ff195735%28v=office.15%29.aspx