Link to home
Start Free TrialLog in
Avatar of baileys
baileys

asked on

Printing an Access Report from VB

How do you print an Access Report from VB.  I need detailed instructions!!  This is urgent, the project I am working on is due in two weeks.

Sheila
Avatar of baileys
baileys

ASKER

The report needs to be preview before printing.

Sheila
Avatar of Axter
Use the following command:

DoCmd.OpenReport "MyReportName", acNormal
Sheila:
      I think this is what you are looking for:


' **********************************************************************
' * Comments : Use OLE automation to print Access reports
' *
' *
' **********************************************************************

Sub PrintReport(ByVal DBPath As String, ByVal ReportName As String, Optional OpenMode As Integer, Optional Filter As String, Optional Criteria As String)
' #VBIDEUtils#************************************************************
' * Programmer Name : Waty Thierry
' * Web Site : www.geocities.com/ResearchTriangle/6311/ 
' * E-Mail : waty.thierry@usa.net
' * Date : 9/10/98
' * Time : 15:00
' * Module Name : Report_Module
' * Module Filename :
' * Procedure Name : PrintReport
' * Parameters :
' * ByVal DBPath As String
' * ByVal ReportName As String
' * Optional OpenMode As Integer
' * Optional Filter As String
' * Optional Criteria As String
' **********************************************************************
' * Comments : Use OLE automation to print Access reports
' *
' *
' **********************************************************************

Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase (DBPath)

'********************************************************
'Access constants for OpenMode are
'acNormal - Print (default)
'acPreview - Print Preview
'acDesign - Design Edit Mode
'********************************************************
appAccess.DoCmd.OpenReport ReportName, OpenMode, Filter, Criteria

'********************************************************
'if open mode is Preview then don't quit Access this can
'also be deleted if you do not want Access to quit after
'printing a report
'********************************************************
'If OpenMode <> acPreview Then
' appAccess.Quit
'End If
Set appAccess = Nothing

End Sub



John
Avatar of baileys

ASKER

Johnny6 please respond.  Your answer is what I wanted.  Thanks
ASKER CERTIFIED SOLUTION
Avatar of John Sobiranski
John Sobiranski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of baileys

ASKER

Thanks again for your help!!