Re: How to Run an Access Report

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Graham R Seach (gseach_at_NOSPAMpacificdb.com.au)
Date: 07/29/04


Date: Thu, 29 Jul 2004 11:15:22 +1000

Just off the top of my head...

1. Add a reference to Access.
2. Add the following air code:
    'Declarations Section
    Private acc As Access.Application

    Public Sub OpenAccessReport(sReportName As String)
        Set acc = New Access.Application

        acc.OpenCurrentDatabase "path to database", False
        acc.DoCmd.OpenReport sReportName, acViewPreview
        acc.DoCmd.Close acReport, sReportName
        Stop
        acc.CloseCurrentDatabase
        Set acc = Nothing
    End Sub

Since Access doesn't expose an automation library, you'll need some way of
detecting when the report closes/prints. I'd suggest:
    Private WithEvents rpt As Access.Report
...and using a report event, such as Close(), to then trigger your code to
destroy the Access (and Report) objects.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html

"Kobeobo" <kobebus@erols.com> wrote in message
news:41081DE4.FAB55537@erols.com...
> Hi guys, sorry if this has been covered before...
>
> I have a VB6 program using Access V2000 as the database. The Access DB
> has several reports,
> does anyone know how to execute (run) an Access report from within VB6?
>
> Thanks
> Baz
>



Relevant Pages

  • Re: Helmets +/- Safety
    ... The DfT report makes ... I think that reference 4 is of major significance although you may have ... laws - not review the efficacy of cycle helmets / head injuries. ... weighed against the costs. ...
    (uk.rec.cycling)
  • ANS: Erroneous Compiler Errors When Building
    ... will sometimes report a selection of errors that are quite false. ... a reference to another assembly when it already has a reference. ... It turns out that the fault lies with the compiler. ... as the compiler will not build assemblies that haven't changed (I ...
    (microsoft.public.dotnet.languages.vb)
  • Re: DH Query By Form
    ... Did you set a reference to the DAO ... Are you getting any other errors after clicking the Run Report button? ... I modified this query to reference my table, ... Duane Hookom wrote: ...
    (microsoft.public.access.queries)
  • Re: The Asymmetry of Identity
    ... Nobody wants sqrt4, a reference, for its own sake. ... analyze them a bit further to get meaning that wasn't already evoked ... report reports external properties. ... survey to others. ...
    (sci.logic)
  • Re: The Concept of Eternal Damnation in Islam
    ... is the reference to the Rehman Report itself. ... That is why the Report goes PLONK!! ... Pakistan was the then chief justice of the Supreme Court. ...
    (alt.religion.islam)