General discussion
September 28, 2003 at 10:52 PM
tptbusines_98

Automating MS-Access 97 Reports

by tptbusines_98 . Updated 23 years ago

Hello,
I am trying the example: “How to Use Automation to Print Microsoft Access
Reports” in MS-Access 97.

I have copied the following text:
1. Open Microsoft Access.
2. Create a new, blank database.
3. Create a module and type the following in the Declarations section:
Option Explicit
‘ In other applications like Microsoft Visual Basic, you can include a reference to Microsoft Access to gain the use of Access constants. Or, use the following
‘ constant values…
‘ Global Const acNormal = 0
‘ Global Const acDesign = 1
‘ Global Const acPreview = 2
‘————————-
‘ Application Quit options… saves all objects without displaying a dialog box:
‘ Global Const acSaveYes = 0 displays a dialog box that asks whether you want to save any database objects that have been changed but not saved:
‘Global Const acPrompt = 1 quits Microsoft Access without saving any objects:
‘ Global Const acExit = 2
4. Type the following procedure:
Function OLEOpenReport(strDBName As String, _strRptName As String_ Optional ByVal intDisplay As Variant, _ Optional ByVal strFilter As Variant, _ Optional ByVal strWhere As Variant) As Boolean On Error GoTo OLEOpenReport_Err

‘ Create Automation object.
Dim objAccess As Object
Set objAccess = CreateObject(“Access.Application”)

‘ Open the supplied database.
‘ Optional parameter at the end of statement
‘ indicates exclusive mode if set to True…
objAccess.OpenCurrentDatabase strDBName, False

‘ The OpenReport method uses the following arguments…
‘ Report Name – Name of the report object.
‘ View – Display in Print Preview or send to printer.
‘ acNormal – Print report
‘ acDesign – open report in design (n/a in runtime)
‘ acPreview – open in preview window
‘ Filter Name – Name of a saved filter query.
‘ Where Condition = valid SQL where condition.

This discussion is locked

All Comments