Solved

Open Access Reports in vb.net

Posted on 2006-06-30
4
666 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 84

Accepted Solution

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

0
 
LVL 3

Expert Comment

by:IainTheVBALearner
Comment Utility
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
Comment Utility
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
Comment Utility
...and you get intellisense.  I was just being lazy!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now