print reports

i made reports at access,
i want to print them from visual basic.
how can i print and preview reports
made by access in visual basic code ?
ruby_yeheskelAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AndySulzConnect With a Mentor Commented:
you can not preview an access report with out Access open.

First Of All in VB, goto Project -> Refferences and make sure Microsoft Access is checked ...

this is how to preview a report with vb...

DoCmd.OpenReport "ReportName", acPreview, "", ""

to print a report out....

DoCmd.OpenReport "ReportName", acNormal, "", ""

....if you want to preview the reports with out Access....the i would invest in Crystal Reports.
0
 
watyCommented:
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 15/06/99
' * Time             : 10:09
' **********************************************************************
' * 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

0
 
ruby_yeheskelAuthor Commented:

  i'm writing this script but i have two problems :

Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase (DBPath)
appAccess.DoCmd.OpenReport ReportName, OpenMode
Set appAccess = Nothing


1 ) i want to use the report's without opening the access      application

2) how do i preview the report's

0
 
yjtCommented:
Do you want to use the data report method? You can directly call up a preview report in Access...
0
 
ruby_yeheskelAuthor Commented:
how can i veiw\print reports done by
access through visual basic6 without
opening the access it self ?
(like accessing mdb files without
 the necessity of opening the access
 application).
 
p.s.

ready to pay for ocx's
 
0
All Courses

From novice to tech pro — start learning today.