General discussion

Locked

Access Reports

By fbarr_taz ·
Is it possible to use VBA code to open and run a Microsoft Access Report?

In other words a VB front end that would permit a user to select a report that was saved in an ACCESS MDB.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access Reports

by roc180 In reply to Access Reports

Lets say you have a button on your form, with in the On_Click event of your button use the following code:

DoCmd.Openreport "ReportName",acViewNormal 'Print report

If you want to just open the report: DoCmd.Openreport "ReportName",acViewPreview

If you want some example code that will read all your reports into a combo box and allow your users to select one and then view it, let me know and I can E-mail it to you.

Good Luck

Neal Martinelli

Collapse -

Access Reports

by roc180 In reply to Access Reports

I just had a thought, when you said VBA code from a VB front end, do you mean your front end is a Visual Basic form, or are you refering to an Access VBA form? If your front end is Visual Basic my above code will not work. It is possible to open an Access report from VB, but you wouldn't want to, a better option would be using VB6's built in report generator or Crystal reports.

Collapse -

Access Reports

by fbarr_taz In reply to Access Reports

I am sorry I didnt make it clear, This would be a Visual Basic form. The purpose is to take advantage of over 300 reports already designed and running in access. I dont want to redesign them in Crystal.

Collapse -

Access Reports

by VinnyD In reply to Access Reports

Yes it is possible. In VB you must include the Microsoft Access Object as part of the project (under Project References).

The following code sample opens an access database and runs the report from the access database from a command button.

This example prints the report to the default printer when it is run.

Private Sub Command1_Click()

Dim appAccess As New Access.Application

Const conPath As String = "C:\outlook\db1.mdb"

With appAccess
' Open the Outlook database.
.OpenCurrentDatabase conPath
' Open the Find duplicates report.
.DoCmd.OpenReport "Find duplicates for tblContacts"
End With

End Sub

Collapse -

Access Reports

by fbarr_taz In reply to Access Reports

Thank you very much that is exactly what I was looking for.

Collapse -

Access Reports

by fbarr_taz In reply to Access Reports

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums