Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing an access report from within VB

Status
Not open for further replies.

Eradic8or

Programmer
Oct 29, 2000
159
GB
I have developed a front end which allows users to log support calls from thier PC and log it directly into an access databse.
There is a report from within the database that I would like printed after the user has submitted thier request. although I have written my own print routine, I would like to use the reprt from within Access. Is there a quick & easy way to do this. I would have to pass the report some parrameters but I don't mind that.

Thanks,
 
Dim ac As Access.Application

Set ac = New Access.Application

' put the path to your database in here
ac.OpenCurrentDatabase ("c:\myfolder\mydb.mdb")

' by default, the OpenReport method of the
' DoCmd object will send the report to the printer

ac.DoCmd.OpenReport "myreportname"

ac.CloseCurrentDatabase ' close the database
 
The routine Perogy gave you is perfect, however, there is one other step that you would need to do and that is to set a reference to the appropriate library.

In your VB project, click on Project/References. Locate Microsoft Access X.X Object Library and check it (I'm using Microsoft Access 9.0 Object Library. I don't know what it will be for you, but regardless, you need the reference or when you try to declare ac As Access.Application your program won't know what the heck you are talking about.)
 
The problem with this method is that it requires access to be installed on the host machine which is not always the case.

eradic8or.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top