Solved

Microsoft Access Reports Automation

Posted on 2001-06-23
3
207 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 …
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.
Suggested Courses

628 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