I'm a novice.
I wonder how to print a report by VB?
The DataReport seems to need changeless DataSource,but i want to change the datasource at runtime.
How to manage it?
Anyone be kind enough to tell me?
Thanks beforehand.
Printable View
I'm a novice.
I wonder how to print a report by VB?
The DataReport seems to need changeless DataSource,but i want to change the datasource at runtime.
How to manage it?
Anyone be kind enough to tell me?
Thanks beforehand.
This should help
Dim appAccess As Access.Application
Dim strDB As String
Const strConPathToSamples = "D:\Program " _
& "Files\Microsoft _
Office\Office\Samples\Contact.mdb"
" this is the path to the DB
strDB = strConPathToSamples & "Contact.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strConPathToSamples
'appAccess.DoCmd.OpenForm "Orders" ' will open the form
appAccess.DoCmd.OpenReport "ActionItems",
acViewPreview ' will open the report, if in preview will show
' if in acviewNormal will print
appAccess.Visible = True ' just shows access
then to change to a new DB or report, just close the object
set appAccess = Nothing
then rerun above with new Parameters
[Edited by jtm7699 on 07-05-2000 at 04:13 PM]