Re: How to Run an Access Report
From: Graham R Seach (gseach_at_NOSPAMpacificdb.com.au)
Date: 07/29/04
- Next message: Graham R Seach: "Re: Breaking a reference via code"
- Previous message: John Vinson: "Re: RecordSet shows DOUBLE the actual no. of records"
- In reply to: Kobeobo: "How to Run an Access Report"
- Next in thread: John Nurick: "Re: How to Run an Access Report"
- Messages sorted by: [ date ] [ thread ]
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
>
- Next message: Graham R Seach: "Re: Breaking a reference via code"
- Previous message: John Vinson: "Re: RecordSet shows DOUBLE the actual no. of records"
- In reply to: Kobeobo: "How to Run an Access Report"
- Next in thread: John Nurick: "Re: How to Run an Access Report"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|