Solved

Microsoft Access Reports Automation

Posted on 2001-06-23
3
200 Views
Last Modified: 2013-11-28
I'm Using Visual Basic To Open An Access Report Like This:

Private Sub CmdOpenReport_Click()
  RunReport "report1", "Customers.CustomerID='11111111'"
End Sub

Public Sub RunReport(strReport As String, Optional WhereCondition As String)
   Dim mobjAccess As Object
   Set mobjAccess = New Access.Application
   mobjAccess.DoCmd.Hourglass True
   ' Open the database
   mobjAccess.OpenCurrentDatabase CurrentDbPath
   ' Open the report in preview mode
   mobjAccess.DoCmd.OpenReport strReport, acViewPreview, , WhereCondition
   ' Maximize the report window
   mobjAccess.DoCmd.Maximize
   ' Show the Access window
   mobjAccess.Visible = True
   mobjAccess.DoCmd.Hourglass False
End Sub

My Problem Is That I Want To Leave Access Application Open After Leaving The "RunReport" Sub And Let The User Print His Report Wherever He Like.
That's Why I'm Not Closing My "mobjAccess" Object At The End Of My Sub.

So Why When I'm Leaving The Sub The Access Application
Is Closing ?

How Can I Leave The Access Application(My Specific Report) Open ?????????????????


0
Comment
Question by:ruby_yeheskel
3 Comments
 
LVL 3

Accepted Solution

by:
kfrick earned 50 total points
Comment Utility
your mobjAccess object ceases to exist when this sub is exited.

Try moving the Dim mobjAccess as Object line to the definitions area of your code. It will then cease to exist when the form is unloaded.

BTW, this won't work if you wishto close your VB app and leave Access open.

-kf
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Only a think:
Dim mobjAccess As Object   ' hummm....
Dim mobjAccess As Access.application     ' :)
 
0
 

Author Comment

by:ruby_yeheskel
Comment Utility
kfrick,

Thanks

You Know Sometimes The Head Is Not Working.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

763 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

7 Experts available now in Live!

Get 1:1 Help Now