Solved

Open Access Reports in vb.net

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

813 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