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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
AndySulzCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.