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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Access Reports in VB

Status
Not open for further replies.

Egiallombardo

Programmer
Jun 18, 2001
4
0
0
US
Anyone know of a plugin for vb that would allow you to run Reports created in an Access Database?
 
This may or may not help....

I don't know of a 'plug-in' per se, but if you haven't already tried Automation (Reference the Microsoft 9.0 Object Library), my guess is that it would work for you. However, this may not be an acceptable alternative because it forces users to run an instance of MSAccess every time they want ot view or print a report, which requires it to be loaded on their machine.

 
Here's the code I use, but like Sheffield said, it requires that the user has Access installed:

'requires Microsoft Access Object Library
'exports to Excel Spreadsheet, play with
'object browser to see what else is available

Dim MSAccess as Access.Application
Set MSAccess = CreateObject("Access.Application")

MSAccess.OpenCurrentDatabase MyDBFileName

MSAccess.DoCmd.acTransferSpreadsheet acExport, Excel97, MyTableName, MyDestPath
 
Definately some good stuff from MikeCox!

Just an FYI, here is how I print MS Access reports in VB 6.0:

Code:
Option Explicit
'References MS Access 9.0 Object Library
Dim MSAccess as Access.Application

Private Sub cmd_Report_Click()
    Set MSAccess as New Access.Application
    MSAccess.OpenCurrentDatabase ("c:\vb\MyBusiness.mdb")
    
    ' The following line needs to be added, although I 
    ' don't believe it makes sense.
    MSAccess.DoCmd.OpenReport "rptEmployee", acViewPreview
    
    MSAccess.DoCmd.OpenReport "rptEmployee", acViewNormal
    MSAccess.CloseCurrentDatabase
    Set MSAccess = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top