Printing Access 97 Reports from VB 5.0 program

Printing Access 97 Reports from VB 5.0 program

Post by Khodr Ghatta » Wed, 16 Sep 1998 04:00:00



How can I print a Report created in Access 97 from within VB program (NOT
from Access program).
From my VB application I am accessing an Access 97 database that contains:
Tables, Queries and Reports. I can access the Tables and Queries using
OpenRecordset method, but for Reports I have No clue how to do so.

Any help will be highly appreciated.
Could you please send me a copy (Cc:) of your answer to my email address:

Thanks again

Khodr Ghattas

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by John Spenc » Wed, 16 Sep 1998 04:00:00


Tables and queries (which are treated as tables) are part of the Jet Engine.
All the rest are Documents that are created by Access. If your VB program
has access to Access, you can create an Access process with the command line
requesting that the report be printed. See Access shortcuts.
Anyone else has a way to do it from VB, I would like to hear of it myself.
John

>How can I print a Report created in Access 97 from within VB program (NOT
>from Access program).
>From my VB application I am accessing an Access 97 database that contains:
>Tables, Queries and Reports. I can access the Tables and Queries using
>OpenRecordset method, but for Reports I have No clue how to do so.

>Any help will be highly appreciated.
>Could you please send me a copy (Cc:) of your answer to my email address:

>Thanks again

>Khodr Ghattas


 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Erick Wood » Thu, 17 Sep 1998 04:00:00


Buy vsReports from Videosoft at Videosoft.com

I haven't used it - I hear from some it is great, others say it is very
slow...

E


>How can I print a Report created in Access 97 from within VB program (NOT
>from Access program).
>From my VB application I am accessing an Access 97 database that contains:
>Tables, Queries and Reports. I can access the Tables and Queries using
>OpenRecordset method, but for Reports I have No clue how to do so.

>Any help will be highly appreciated.
>Could you please send me a copy (Cc:) of your answer to my email address:

>Thanks again

>Khodr Ghattas

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Bj?rn Ivar Katl » Thu, 17 Sep 1998 04:00:00


Use object automation.  It will do the trick for you and you will find
that you can do a lot more that just printing reports.

Project/References: add "Microsoft Access 8.0 Object library",
and you can do everything you wants to and more....
Press F2 after you have selected Microsoft access 8.0 Object lib.  and
you will get the object browser...

You might find articles about the subject in VB Programmers Journal..

Bjoern Ivar Katla


>How can I print a Report created in Access 97 from within VB program (NOT
>from Access program).
>From my VB application I am accessing an Access 97 database that contains:
>Tables, Queries and Reports. I can access the Tables and Queries using
>OpenRecordset method, but for Reports I have No clue how to do so.

>Any help will be highly appreciated.
>Could you please send me a copy (Cc:) of your answer to my email address:

>Thanks again

>Khodr Ghattas

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by P.R.Joh » Thu, 17 Sep 1998 04:00:00



>Use object automation.  It will do the trick for you and you will find
>that you can do a lot more that just printing reports.

>Project/References: add "Microsoft Access 8.0 Object library",
>and you can do everything you wants to and more....
>Press F2 after you have selected Microsoft access 8.0 Object lib.  and
>you will get the object browser...

>You might find articles about the subject in VB Programmers Journal..

>Bjoern Ivar Katla


>>How can I print a Report created in Access 97 from within VB program (NOT
>>from Access program).
>>From my VB application I am accessing an Access 97 database that contains:
>>Tables, Queries and Reports. I can access the Tables and Queries using
>>OpenRecordset method, but for Reports I have No clue how to do so.

>>Any help will be highly appreciated.
>>Could you please send me a copy (Cc:) of your answer to my email address:

>>Thanks again

>>Khodr Ghattas

This from Auto97.exe (no idea where I found it on MS's site):

[Quote]

Previewing or Printing a Microsoft Access Report

The following code uses Automation to preview or print a report in the
Northwind database.  This procedure requires a reference to the Microsoft
Access 8.0 object library in order to run.  To reference this object
library, click References from the Tools menu in a module and check the
Microsoft 8.0 object library.

Sub PrintAccessReport(dbName As String, rptName As String, _
                      Preview As Boolean)

'Previews or Prints the specified report in the specified database.

'Once the report has printed, or once the preview window is closed,
'the instance is terminated.
'
'Calling example:
'PrintAccessReport "C:\Northwind.mdb", "Sales by Category", True

'This procedure requires the Microsoft Access 8.0 object library be
'referenced under Tools, References in your module.

    Dim objAccess As Access.Application
    On Error GoTo PrintAccessReport_ErrHandler

    Set objAccess = CreateObject("Access.Application")

    With objAccess
        .OpenCurrentDatabase filepath:=dbName
        If Preview Then 'preview report on screen
            .Visible = True
            .DoCmd.OpenReport reportname:=rptName, View:=acViewPreview

        Else  'print report to printer
            .DoCmd.OpenReport reportname:=rptName, View:=acNormal
            DoEvents 'allow report to be sent to printer
        End If
    End With

    Set objAccess = Nothing
    Exit Sub
PrintAccessReport_ErrHandler:
    MsgBox Error$(), , "Print Access Report"
End Sub

[End Quote]

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Harlan Messinge » Thu, 17 Sep 1998 04:00:00



: Use object automation.  It will do the trick for you and you will find
: that you can do a lot more that just printing reports.

: Project/References: add "Microsoft Access 8.0 Object library",
: and you can do everything you wants to and more....
: Press F2 after you have selected Microsoft access 8.0 Object lib.  and
: you will get the object browser...

: You might find articles about the subject in VB Programmers Journal..

An important point: the app has to be running on a computer that has
Access installed on it, since that's where the functionality lies.

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Rolando Ramire » Fri, 18 Sep 1998 04:00:00


Hi all :

Quote:>Use object automation.  It will do the trick for you and you will find
>that you can do a lot more that just printing reports.

What happens if the underlying query of a report has parameters ?

Quote:>Project/References: add "Microsoft Access 8.0 Object library",
>and you can do everything you wants to and more....

What about redistributing the application, you have to install Access in the
PCs where the app will run or the VB setup wizard can guess what dlls to
pack with the app ??

see you,
Rolando

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Matt Chil » Sat, 19 Sep 1998 04:00:00


Rolando,

You can only use this functionality on a machine that has Access
installed.  If you need reporting functionality for distribution on
clients that don't have Access, then you will have use Crystal, Active
Reports, or do your own reports using the Print capabilities built in to
VB.

Matt


overheard saying...

Quote:> Hi all :

> >Use object automation.  It will do the trick for you and you will find
> >that you can do a lot more that just printing reports.

> What happens if the underlying query of a report has parameters ?

> >Project/References: add "Microsoft Access 8.0 Object library",
> >and you can do everything you wants to and more....

> What about redistributing the application, you have to install Access in the
> PCs where the app will run or the VB setup wizard can guess what dlls to
> pack with the app ??

> see you,
> Rolando

--
Matt Childs

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Mike Robbin » Sun, 20 Sep 1998 04:00:00


    I've used this type of method in a few programs and want to point out
one drawback. In order to preview the report, you must make the Access
automation object visible. It comes up in front of your VB program so the
user can preview the report. When the user is done previewing, they must
click the "Close" button and minimize the Access screen. The first tendency
of most users is to close Access by clicking on the close box. Because of
this, you need to make sure you have code that checks to see if your object
variable is Nothing before performing anything else on it.

    Because of this, I've switched to using ActiveReports. These are
compiled in the .exe and are a part of your VB program.

Best,

Mike

Quote:>This from Auto97.exe (no idea where I found it on MS's site):

>[Quote]

>Previewing or Printing a Microsoft Access Report

>The following code uses Automation to preview or print a report in the
>Northwind database.  This procedure requires a reference to the Microsoft
>Access 8.0 object library in order to run.  To reference this object
>library, click References from the Tools menu in a module and check the
>Microsoft 8.0 object library.

>Sub PrintAccessReport(dbName As String, rptName As String, _
>                      Preview As Boolean)

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Kevin C. Dor » Wed, 30 Sep 1998 04:00:00


The problem with using Access reports is that your reporting engine is
VERY HEAVY (you must have the correct version of Access installed on
every system that will run the application). Also, it will physically
LAUNCH access and if you are doing a previous the user will SEE Access
running.

I find this approach to have BIG drawbacks and advocate using a 3rd
party reporting tool to make your reports. Classically people have
used Crystal Reports, but I am _NOT_ a Crystal Reports fan, although I
used it for a couple years (argh). This year Data Dynamics put out
Active Reports which I find does EVERYTHING I need to do and is almost
as easy to use as the Access report writer.

ALSO, ActiveReports supports unbound reporting which cannot really be
done in either Access or Crystal, so for my needs ActiveReports is
worth EVERY PENNY.

By desing the reports will compile INTO your EXE, but if you are
clever you can make an ActiveX DLL that contains the reports so the
reports can be external, which is also very cool. SO many things can
be done with ActiveReports that cannot be dreamed of with Crystal (or
Access) reports.

ActiveReports distribution is about 800k (uncompressed) as one DLL.
DataDynamics has active and responsive tech support.

Nope, I don't work for DataDynamics, just love their product
Kevin

On Wed, 16 Sep 1998 12:50:56 +0200, "Bj?rn Ivar Katla"


>Use object automation.  It will do the trick for you and you will find
>that you can do a lot more that just printing reports.

>Project/References: add "Microsoft Access 8.0 Object library",
>and you can do everything you wants to and more....
>Press F2 after you have selected Microsoft access 8.0 Object lib.  and
>you will get the object browser...

>You might find articles about the subject in VB Programmers Journal..

>Bjoern Ivar Katla


>>How can I print a Report created in Access 97 from within VB program (NOT
>>from Access program).
>>From my VB application I am accessing an Access 97 database that contains:
>>Tables, Queries and Reports. I can access the Tables and Queries using
>>OpenRecordset method, but for Reports I have No clue how to do so.

>>Any help will be highly appreciated.
>>Could you please send me a copy (Cc:) of your answer to my email address:

>>Thanks again

>>Khodr Ghattas

 
 
 

Printing Access 97 Reports from VB 5.0 program

Post by Jerge » Fri, 02 Oct 1998 04:00:00


Alternatively, if you are really married to Access reports, you can use
VideoSoft's VS-REPORTS tool and control to extract the report from Access 97
into a separate file which can then be run from within VB run-time using
VS's OCX.

>On Wed, 16 Sep 1998 12:50:56 +0200, "Bj?rn Ivar Katla"

>>Use object automation.  It will do the trick for you and you will find
>>that you can do a lot more that just printing reports.

>>Project/References: add "Microsoft Access 8.0 Object library",
>>and you can do everything you wants to and more....
>>Press F2 after you have selected Microsoft access 8.0 Object lib.  and
>>you will get the object browser...

>>You might find articles about the subject in VB Programmers Journal..

>>Bjoern Ivar Katla


>>>How can I print a Report created in Access 97 from within VB program (NOT
>>>from Access program).
>>>From my VB application I am accessing an Access 97 database that
contains:
>>>Tables, Queries and Reports. I can access the Tables and Queries using
>>>OpenRecordset method, but for Reports I have No clue how to do so.

>>>Any help will be highly appreciated.
>>>Could you please send me a copy (Cc:) of your answer to my email address:

>>>Thanks again

>>>Khodr Ghattas