Opening a Report in a different database.

G

genojoe

I want to open an Access report from a VB.NET application. The code (tweaked
for VB.NET) shown below prints to paper a report from either VB.NET or from a
different Access database. This solution has two problems that I have not
been able to solve.

(1) When running code, I get a dialog box titled "Security Warning" with
command buttons for "Cancel", "Open", or "Info" when the OpenCurrentDatabase
statement executes. I would like to bypass this dialog.

(2) I would like to display the report on the screen. I have added
"Access.AcView.acViewPreview" to the OpenReport line but no report is
displayed.

Since my data is in Access, I would like to avoid using Crystal Reports or
other Report engines if possible and use Access.

My code is shown below. If anyone can point me to information about using
Access reports from VB.NET, it would be much appreciated. I have only found
minimal references to this topic.

Dim AccessApp As Access.Application
Private Sub Command1_Click()
Set AccessApp = CreateObject("Access.Application")
AccessApp.OpenCurrentDatabase ("E:\HouseAccounts.mdb")
AccessApp.DoCmd.OpenReport "CustomerNames"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top