Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Open Access Reports in vb.net

Posted on 2006-06-30
4
Medium Priority
?
944 Views
Last Modified: 2013-11-28
Hello!

I tried to make my dotnet win form show an Access Report. I have tried the following code,

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

            Dim acc_App As Access.Application = New Access.Application 'use this early binding if only have one version of access
           'Dim acc_App As Access.Application = CreateObject("Access.Application")
            acc_App.OpenCurrentDatabase("C:\myAccess.mdb", True)
            'above line will make msaccess.exe running as seen under taskmanager
            acc_App.DoCmd.OpenReport("test", Access.AcView.acViewPreview)
            acc_App.DoCmd.OpenReport("rptCustOrderAck", Access.AcView.acViewPreview)
            acc_App.Quit()

        End Sub

The first OpenReport did not bring anything to screen, and second one caused error meesage in the Access, ( as it should if I run previw after I launched the mdb).

What is missing here? Thanks!
0
Comment
Question by:ommer
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 17021659
Did you actually see the Access app open? Often you have to set .Visible=True (after opening).

0
 
LVL 3

Expert Comment

by:IainTheVBALearner
ID: 17026097
Hello

I got this to work.  

I didn't reference the Access object library, I just used an object.

I think the bit you're missing is making Access visible - as LSM said.

        Dim acc_App As Object

        acc_App = CreateObject("Access.Application")

        acc_App.OpenCurrentDatabase("C:\Projects.mdb", True)
        acc_App.visible = True
        acc_App.DoCmd.OpenReport("Report1", 2)
        acc_App.DoCmd.OpenReport("Report2", 2)

Iain

0
 

Author Comment

by:ommer
ID: 17026918
I will try that when I get to work. One reason that I choose the library is that I want to set the where condition and OpenArgs and pass them to the reports.
0
 
LVL 3

Expert Comment

by:IainTheVBALearner
ID: 17027263
...and you get intellisense.  I was just being lazy!
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question