I have some reports saved in an Access Database, and I need VB to print them. How do I get my VB app to find these reports and print or preview them?
Printable View
I have some reports saved in an Access Database, and I need VB to print them. How do I get my VB app to find these reports and print or preview them?
Make a reference to MS Access in the project.
Add the following code
'
' Setup reference to Access
'
Dim MSAcc As Access.Application
Set MSAcc = New Access.Application
'
' ok connect your database
'
MSAcc.OpenCurrentDatabase("c:\whatever.mdb")
' by default, the OpenReport method of the
' DoCmd object will send the report to the printer
'
MSAcc.DoCmd.OpenReport "MyReport"
' close the database
MSAcc.CloseCurrentDatabase
Still mucking around with this, but hope it gives you a guideline
That's about all it takes. Just remember
Thanks, I can get that to do what I need. I also found that if I changed the OpenReport line to:
MSAcc.DoCmd.OpenReport "MyReport", 2
It will open in preview mode.
Still playing with the code to keep our end user happy so will include your code with maybe a tick box or something to allow mode selection.