Solved

VB code to call Access report

Posted on 1998-07-23
3
218 Views
Last Modified: 2013-11-28
I would like to call an access report from VB.
I’ve tried
db.myreport  = 1

That doesn’t work. What is the correct VB code to do this?

Thanks  
0
Comment
Question by:g6yassin
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1466569
g6yassin,
Do you have access in your machine? I have the code for OLE automation. If you like, just click on my name and see the paq. It only cost 10 points. Then you can delete this one.
Regards
Dalin
0
 
LVL 9

Accepted Solution

by:
Dalin earned 30 total points
ID: 1466570
g6yassin,

Here is the code to open it with OLE automation: I realize that it may be quite a few paq to look for. If you already get it from the paq, reject my answer.
Regards
Dalin


       Have a command Named OpenAccessReport, in the click event, put the code:

           'handle errors
           On Error GoTo LoadError
             
           'change the mouse
           Screen.MousePointer = vbHourglass
             
           'create new object variable
           Dim objAccess As New access.Application
             
           'open database
           objAccess.OpenCurrentDatabase ("YourDBNameWithPath.MDB")
                 
           'maximize access
           objAccess.DoCmd.Maximize
             
           'run report in print preview mode
           objAccess.DoCmd.OpenReport "YourReportName", acViewPreview
           
           'restore report
           objAccess.DoCmd.Restore
             
           'maximize report
           objAccess.DoCmd.Maximize

           'change the mouse
           Screen.MousePointer = vbDefault
             
           'exit
           Exit Sub
             
       LoadError:
           'change the mouse
           Screen.MousePointer = vbDefault
             
           'show error
           MsgBox Error$
             
           Resume Next
0
 

Author Comment

by:g6yassin
ID: 1466571
Dalin
I am sorry for adding my comment a little late, but I am new to
the system and I am getting to know how the it works better
now. Your code worked well but the window starts minimized. I would like it start open.
Thanks
Yassin
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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 …

685 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