Solved

VB code to call Access report

Posted on 1998-07-23
3
206 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

759 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

21 Experts available now in Live!

Get 1:1 Help Now