Solved

Microsoft Access Reports Automation

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

911 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

25 Experts available now in Live!

Get 1:1 Help Now