Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 - Run an Access Report from VB6

Posted on 2008-10-24
2
Medium Priority
?
150 Views
Last Modified: 2010-04-30
I have a report (ClosingRpt) that was created in Access 2002.  I wish to run that report from my VB6 program by pressing a Command Button (RunClosingRpt).

Do I use OLE?  If so, how.  If not, what do I do?

When the report has been run I want control to return to the VB6 program named "Evaluation"

thanks
0
Comment
Question by:ljcor
[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 Comments
 
LVL 2

Accepted Solution

by:
Adel87 earned 2000 total points
ID: 22802153
The attached code is supposed to do the trick :

before adding this code to your command button please do the following :
1- in VB6 go to 'Project' menu and choose ''References'
2- check the following refrence or the relevent version that you have :
'Microsft Access 10.0 Object Library'
3- press ok

don't forget to change the strPath the path you have your file in as this code asumes the Access mdb file to be on the same folder as the executable. and change db.mdb with the correct file name for your database file.

put the first part of the code (before the comment) in the command button and the second part in the (form_unload) event.

Please contact me if you need further assistance.

Best Regards,
Dim AcApp As Access.Application
Set AcApp = New Access.Application
Dim strPath As String
 
strPath = App.Path
strPath = strPath & "\db.mdb"
 
AcApp.OpenCurrentDatabase strPath
AcApp.Visible = True
AcApp.DoCmd.OpenReport "ClosingRpt", acViewPreview
AcApp.DoCmd.Maximize
 
'don't forget to dispose of the object when you close the form you are calling from, _
'otherwise repeated calls will end up with loads of instances of MSAccess running on your PC
 
AcApp.Quit
Set AcApp = Nothing

Open in new window

0
 

Author Closing Comment

by:ljcor
ID: 31509861
I thank you very much for this code.
Jack
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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