Solved

VB6 - Run an Access Report from VB6

Posted on 2008-10-24
2
145 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 500 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 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