473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Prevent application from closing when New Access.Application sub exits.

We use an Acess Database as a menu of Access Databases. It worked fine until we switched to Office 2007 from 2003. Code is below:
Expand|Select|Wrap|Line Numbers
  1. Private Sub DisclosureQAOPen_Click()
  2. On Error GoTo Err_DisclosureQAOPen_Click
  3.  
  4.     Dim AccApp As Access.Application
  5.     Dim str As String
  6.  
  7.     str = "\\Fanniemae.com\corp\DC\Shared\MF\MBS\GenDisc\Monitoring\QA\Disclosure QA.mdb"
  8.     Set AccApp = New Access.Application
  9.  
  10.     With AccApp
  11.     .OpenCurrentDatabase str
  12.     .Visible = True
  13.     End With
  14.  
  15.  
  16. Exit_DisclosureQAOPen_Click:
  17.     Exit Sub
  18.  
  19. Err_DisclosureQAOPen_Click:
  20.     MsgBox Err.Description
  21.     Resume Exit_DisclosureQAOPen_Click
  22.  
  23. End Sub
==========================================
The requested database closes at "Exit Sub" step under Exit_Disclosure QAOpen_Click:

We do not want the requested database to closed until closed by the user. Then return to Access Menu database.
Dec 10 '12 #1
3 1661
TheSmileyCoder
2,322 Expert Mod 2GB
I am not sure this will work, but try just before the exit:
Expand|Select|Wrap|Line Numbers
  1. Set accApp =Nothing
Dec 10 '12 #2
ADezii
8,834 Expert 8TB
You need to 'Widen the Scope' of the AccApp Variable, either Privately in the Form's Class Module, or Publically in a Standard Code Module. One the Click() Event is exited, AccApp has no meaning.
Dec 10 '12 #3
NeoPa
32,556 Expert Mod 16PB
It closes because AccApp is declared on line #4 within the procedure. This variable has a scope which is local to that procedure so when the procedure exits the variable is deleted and cleared up (which includes closing the application held within it).

You need to ensure the variable is declared somewhere that has adequate scope for how you're planning to use it. In this case I would suggest a Public variable in either a Standard Module or a Form Module you know won't be closed while you still need the opened application.

Some basic instructions for using Application Automation.
Dec 11 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: danny | last post by:
Is there a way I can prevent the browser window from being closed? I'd like to make sure the browser window only closes programatically (I want to make sure the user enters data before moving on)....
0
by: Erwin | last post by:
Hi, I am trying to resolve a problem i am having . I am testing an application that is written in C#.NET. When i do my testrun on a system with an AGP videocard everything runs ok, but when i...
5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
0
by: M | last post by:
I installed the Visual Basic .NET Resource Kit. When I click 'Visual Basic .NET Resource Kit' the page at 'http://localhost/VB.NETResourceKit/Welcome.aspx' show: Server Error in...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
38
by: Oldie | last post by:
I have built an MS Access Application under MS Office XP (but I also own MS Office 2000). I have split the application in the pure database tables and all the queries, forms, reports and macro's. ...
20
by: joseph_gallagher | last post by:
Hi, I've recently ported a .Net 1.1 application to .Net 2.0 and the one new feature that is getting on my nerves is that when there is an unhandled exception the application completely crashes,...
1
by: rajalingam | last post by:
Server Error in '/library' Application. -------------------------------------------------------------------------------- Server cannot access application directory 'F:\Library Latest Code\'. The...
4
by: JB | last post by:
Hi All, I need to write my first "distributed" application and due to my lack of knowledge and experience in that area, I'm stuck on the first big design decision. Reading a lot on distributed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.