Page 1 of 1

How to Run MS-Access Report via VBScript

PostPosted: Mon Nov 29, 2010 4:46 pm
by David de Argentina
Hi all,

This function allow to NeoBook calls to a MS-Access Report.
It has 2 parameters
[%1] = Database Name
[%2] = Report Name

the code of the function is the following

Code: Select all
Dim oAccess, db, report

const acQuitSaveNone = "2"
const acViewPreview = "2"
const acViewNormal = "0"
const acOutputReport = "3"
const acSendReport = "3"
const acFormatRTF="Rich Text Format (*.rtf)"
const acFormatXLS="Microsoft Excel 97-2002 (*.xls)"
const acFormatSNP="Snapshot Format (*.snp)"
const acFormatHTML="HTML (*.html)"

db = "[%1]"
Report = "[%2]"

Set oAccess = CreateObject("Access.Application")
oAccess.Visible = False
oAccess.OpenCurrentDatabase db

With oAccess.DoCmd
.OpenReport Report, acViewNormal
end with
Set oAccess = Nothing

This sample works with the NorthWind sample database (NWind.mdb)

you could download it from:

Enjoy it !

David de Argentina

PostPosted: Mon Nov 29, 2010 8:51 pm
by eddy current
Thank you for sharing David.

Quick question: Which versions of Access have you tested this with?

Thanks -- Glen

PostPosted: Mon Nov 29, 2010 11:30 pm
by David de Argentina
I tested on Access 2003.

I think this function may work on Access 2000 or newer.

My devaluated cent,

David de Argentina