By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

Fire-up MS Access Database from VB and Leave it Running When VB App is Closed?

P: n/a
Hiya,

Anybody know how to do this please? I am opening Access from VB using
the code below. However, I don't want Access to close when objAccess
goes out of scope. I would like Access to remain open - like MS Excel
does if you write similar code.

I am trying to avoid using the Shell function because I don't want to
have to search for MSAccess.exe first.

If you step through the code and click on the Access session before
continuing through the VB code, it seems to know that you have
interacted with it and leaves Access open. I have tried throwing in an
AppActivate "MsAccess" to simulate this but it still closes Access as
soon as the VB code stops running.

I'm testing with VB6 and Access 97.

Thanks.

If chkOpen Then
On Error Resume Next
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase (strFilename)
End If
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 26 Apr 2004 05:01:55 -0700, da**********@uk.royalsun.com (Dave)
wrote:

When the object reference goes out of scope, the object - Access in
this case - is closed. Indeed you would have to use Shell. Look for it
in the default place, and if not found, ask the user to find it for
you, using a File/Open dialog.

-Tom.

Hiya,

Anybody know how to do this please? I am opening Access from VB using
the code below. However, I don't want Access to close when objAccess
goes out of scope. I would like Access to remain open - like MS Excel
does if you write similar code.

I am trying to avoid using the Shell function because I don't want to
have to search for MSAccess.exe first.

If you step through the code and click on the Access session before
continuing through the VB code, it seems to know that you have
interacted with it and leaves Access open. I have tried throwing in an
AppActivate "MsAccess" to simulate this but it still closes Access as
soon as the VB code stops running.

I'm testing with VB6 and Access 97.

Thanks.

If chkOpen Then
On Error Resume Next
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase (strFilename)
End If


Nov 12 '05 #2

P: n/a
Actually, this is not true.

All you have to do is set the Application.UserControl property to True (you
may want to set Application.Visible to true as well!).
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:gr********************************@4ax.com...
On 26 Apr 2004 05:01:55 -0700, da**********@uk.royalsun.com (Dave)
wrote:

When the object reference goes out of scope, the object - Access in
this case - is closed. Indeed you would have to use Shell. Look for it
in the default place, and if not found, ask the user to find it for
you, using a File/Open dialog.

-Tom.

Hiya,

Anybody know how to do this please? I am opening Access from VB using
the code below. However, I don't want Access to close when objAccess
goes out of scope. I would like Access to remain open - like MS Excel
does if you write similar code.

I am trying to avoid using the Shell function because I don't want to
have to search for MSAccess.exe first.

If you step through the code and click on the Access session before
continuing through the VB code, it seems to know that you have
interacted with it and leaves Access open. I have tried throwing in an
AppActivate "MsAccess" to simulate this but it still closes Access as
soon as the VB code stops running.

I'm testing with VB6 and Access 97.

Thanks.

If chkOpen Then
On Error Resume Next
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase (strFilename)
End If

Nov 12 '05 #3

P: n/a
Thanks MichKa, that's exactly what I was looking for. I encountered
this some years ago but couldn't remember it (or find it in any books
or on the web).

Having reviewed the Access 97 documentation it is surprising that it
states that this property is read-only. It's clearly not.

Also, rather surprisingly, I don't need to set the Visible property to
True. My CreateObject("Access.Application") opens a visible instance
of Access. I thought that the default setting of the visible property
was false when automating an object. This suits me this time but still
leaves me a little confused.

Dave.


"Michael \(michka\) Kaplan [MS]" <mi*****@online.microsoft.com> wrote in message news:<40********@news.microsoft.com>...
Actually, this is not true.

All you have to do is set the Application.UserControl property to True (you
may want to set Application.Visible to true as well!).
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.