Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2004, 07:02 PM
Authorized User
 
Join Date: Apr 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default form_close exit's the database

I open an Access project via a VB6 app like so:
Code:
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.OpenAccessProject "C:\Project001.adp"
appAccess.Visible = True
When I close a particular form, the Access database exits. This doesn't happen with all forms and there is a hidden form always open so it's not like it's the last form being closed.

This form isn't bound to a table or anything, rather it's just an unbound text box and a button, the form has no events on_close, it has no event handlers preiod.

Tips:
-This doesn't happen if I open the project without the VB app. (ie. double click it in Windows Explorer)

-I found no difference if I kept the VB app open or closed during the Access project lifespan


Does anyone know why this is happenning?


 
Old April 8th, 2004, 07:43 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your variable appAccess scope is probably within the form that you are closing. Make it global from a module so that it will not close. just make sure that you clean it when you close the database.

How are you executing the code?



Sal
 
Old April 8th, 2004, 08:10 PM
Authorized User
 
Join Date: Apr 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sal,

I have a separate VB6 program that holds the variable appAccess, appAccess doesn't reside in the access database.

But your right, I declared the variable within the form's event handler, limiting the scope. (come to think of it, I wonder why it didn't close the access db sooner!)

It's now declared at the top of the form's code, outside of any functions/subs, making it global to the form. Placing it in a module would have accomplished the same thing I assume.

p.s.
When you put a variable in a module, what the difference between:
Public xxx as Object
&
Global xxx as Object


 
Old April 9th, 2004, 08:43 AM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Making a variable gloval should be only your last resource. You will be using space in memory at all times even if you do not use it if you do not implement it right.

I have never ued Global, but public makes it visible to all your application.



Sal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem to restore database in C#2005 database acmuralee MySQL 0 March 25th, 2008 04:42 AM
Microsoft JET Database Database Engine (0x80040E09 cannielynn0312 Classic ASP Professional 2 December 17th, 2007 02:50 AM
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Copying Table From one Database To Anoter Database jayanth_nadig VB Databases Basics 1 June 19th, 2006 02:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.