Solved

Microsoft Access Reports Automation

Posted on 2001-06-23
3
204 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
[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
3 Comments
 
LVL 3

Accepted Solution

by:
kfrick earned 50 total points
ID: 6221877
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
ID: 6222007
Only a think:
Dim mobjAccess As Object   ' hummm....
Dim mobjAccess As Access.application     ' :)
 
0
 

Author Comment

by:ruby_yeheskel
ID: 6223455
kfrick,

Thanks

You Know Sometimes The Head Is Not Working.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

733 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