Solved

Open Access Reports in vb.net

Posted on 2006-06-30
4
844 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

617 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