Close Database Then Open Database 
Author Message
 Close Database Then Open Database

I am trying to write code to close the currently open database (while
remaining in Access, connected to the current workgroup), and then
opening another database which uses the same workgroup.  I am trying to
use the code below, but it is not amused.  Does someone know how to fix
this ?  Thanks.

*****************************************************************
  Rem ***** Declare local variables *****

  Dim appAccess As Access.Application
  Dim strPath As String
  Dim strDatabase As String

  Rem ***** Open database *****

  strPath = CurDir
  strDatabase = strPath & "\another.mdb"
  appAccess.OpenCurrentDatabase strDatabase

******************************************************************
Rodney M. Gabriel



Mon, 13 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Hi Rodney,
This won't work, you need to shell out to another program in order to open
another database.
Quote:

>I am trying to write code to close the currently open database (while
>remaining in Access, connected to the current workgroup), and then
>opening another database which uses the same workgroup.  I am trying to
>use the code below, but it is not amused.  Does someone know how to fix
>this ?  Thanks.

>*****************************************************************
>  Rem ***** Declare local variables *****

>  Dim appAccess As Access.Application
>  Dim strPath As String
>  Dim strDatabase As String

>  Rem ***** Open database *****

>  strPath = CurDir
>  strDatabase = strPath & "\another.mdb"
>  appAccess.OpenCurrentDatabase strDatabase

>******************************************************************
>Rodney M. Gabriel



Mon, 13 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Hi Rodney,

As I'd mentioned in my other post, this is not possible without using
Sendkeys.

< http://home.att.net/~dashish/modules/mdl0005.htm >

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:I am trying to write code to close the currently open database (while
:remaining in Access, connected to the current workgroup), and then
:opening another database which uses the same workgroup.  I am trying to
:use the code below, but it is not amused.  Does someone know how to fix
:this ?  Thanks.
:
:*****************************************************************
:  Rem ***** Declare local variables *****
:
:  Dim appAccess As Access.Application
:  Dim strPath As String
:  Dim strDatabase As String
:
:  Rem ***** Open database *****
:
:  strPath = CurDir
:  strDatabase = strPath & "\another.mdb"
:  appAccess.OpenCurrentDatabase strDatabase
:
:******************************************************************
:Rodney M. Gabriel
:
:



Mon, 13 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Thanks...and a few SendKeys never hurt anyone   :)

It works, but is there a way to prevent the "Open Database" dialog box from
appearing on the screen, or to make it invisible, or some other trick ?  It
looks a bit funny when it flashes on the screen even for half a second.

By the way, the reason I want to do this is because I have 4 separate
database applications that I want to provide a front-end with 4 buttons, and
when the user selects a button then it opens that database.  You may say,
"why not just import everything into the 1 database?".  Well, I would, but
there is so much reused code in each, that it would step all over itself
without significant work.

Thanks again.

Rodney M. Gabriel

************************************************************************

Quote:

> Hi Rodney,

> As I'd mentioned in my other post, this is not possible without using
> Sendkeys.

> < http://home.att.net/~dashish/modules/mdl0005.htm >

> HTH
> --
> Dev Ashish (Just my $.001)
> ---------------
> The Access Web ( http://home.att.net/~dashish )
> ---------------


> :I am trying to write code to close the currently open database (while
> :remaining in Access, connected to the current workgroup), and then
> :opening another database which uses the same workgroup.  I am trying to
> :use the code below, but it is not amused.  Does someone know how to fix
> :this ?  Thanks.
> :
> :*****************************************************************
> :  Rem ***** Declare local variables *****
> :
> :  Dim appAccess As Access.Application
> :  Dim strPath As String
> :  Dim strDatabase As String
> :
> :  Rem ***** Open database *****
> :
> :  strPath = CurDir
> :  strDatabase = strPath & "\another.mdb"
> :  appAccess.OpenCurrentDatabase strDatabase
> :
> :******************************************************************
> :Rodney M. Gabriel
> :
> :



Tue, 14 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Hi Rodney,

Well, even _one_ Sendkey can hurt _tremendously_ if put in the right, erm.
wrong place, just ask someone who's had this problem, like myself.

Back in the days of Access 95, I had a Sendkeys statement in my app to
manipulate Excel through Automation.  The client's PC had a proprietary
email client which popped up it's entire window when new mail arrived.  My
Sendkeys code unfortunately, matched the key stroke of the email program
which deleted all mail items in the active mail folder.

Needless to say, one fine day, he happened to get an email just when my code
was passing the keystroke to Excel. Well, the rest is _painful_ to remember,
as the user just happened to be the vice president of the entire org. <g>

Reason enough???

I would suggest you use a VB app as a switchboard.

< http://home.att.net/~dashish/modules/mdl0017.htm >

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:Thanks...and a few SendKeys never hurt anyone   :)
:
:It works, but is there a way to prevent the "Open Database" dialog box from
:appearing on the screen, or to make it invisible, or some other trick ?  It
:looks a bit funny when it flashes on the screen even for half a second.
:
:By the way, the reason I want to do this is because I have 4 separate
:database applications that I want to provide a front-end with 4 buttons,
and
:when the user selects a button then it opens that database.  You may say,
:"why not just import everything into the 1 database?".  Well, I would, but
:there is so much reused code in each, that it would step all over itself
:without significant work.
:
:Thanks again.
:
:Rodney M. Gabriel
:
:************************************************************************
:
:> Hi Rodney,
:>
:> As I'd mentioned in my other post, this is not possible without using
:> Sendkeys.
:>
:> < http://home.att.net/~dashish/modules/mdl0005.htm >
:>
:> HTH
:> --
:> Dev Ashish (Just my $.001)
:> ---------------
:> The Access Web ( http://home.att.net/~dashish )
:> ---------------
:>

:> :I am trying to write code to close the currently open database (while
:> :remaining in Access, connected to the current workgroup), and then
:> :opening another database which uses the same workgroup.  I am trying to
:> :use the code below, but it is not amused.  Does someone know how to fix
:> :this ?  Thanks.
:> :
:> :*****************************************************************
:> :  Rem ***** Declare local variables *****
:> :
:> :  Dim appAccess As Access.Application
:> :  Dim strPath As String
:> :  Dim strDatabase As String
:> :
:> :  Rem ***** Open database *****
:> :
:> :  strPath = CurDir
:> :  strDatabase = strPath & "\another.mdb"
:> :  appAccess.OpenCurrentDatabase strDatabase
:> :
:> :******************************************************************
:> :Rodney M. Gabriel
:> :
:> :
:



Tue, 14 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Why can't you have a function that counts the number of open objects and the
issues a docmd.close for every open object?

Randy

Quote:

>I am trying to write code to close the currently open database (while
>remaining in Access, connected to the current workgroup), and then
>opening another database which uses the same workgroup.  I am trying to
>use the code below, but it is not amused.  Does someone know how to fix
>this ?  Thanks.

>*****************************************************************
>  Rem ***** Declare local variables *****

>  Dim appAccess As Access.Application
>  Dim strPath As String
>  Dim strDatabase As String

>  Rem ***** Open database *****

>  strPath = CurDir
>  strDatabase = strPath & "\another.mdb"
>  appAccess.OpenCurrentDatabase strDatabase

>******************************************************************
>Rodney M. Gabriel



Wed, 15 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database


Quote:
> Why can't you have a function that counts the number of open objects and the
> issues a docmd.close for every open object?

The objects are *within* a database.  The aim is to close the database
itself... and then open another one.  Programmatically.

--
Paul Bredbury, http://dialspace.dial.pipex.com/brebs/



Wed, 15 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
I stand corrected !     :)

Rodney M. Gabriel

Quote:

> Hi Rodney,

> Well, even _one_ Sendkey can hurt _tremendously_ if put in the right, erm.
> wrong place, just ask someone who's had this problem, like myself.

> Back in the days of Access 95, I had a Sendkeys statement in my app to
> manipulate Excel through Automation.  The client's PC had a proprietary
> email client which popped up it's entire window when new mail arrived.  My
> Sendkeys code unfortunately, matched the key stroke of the email program
> which deleted all mail items in the active mail folder.

> Needless to say, one fine day, he happened to get an email just when my code
> was passing the keystroke to Excel. Well, the rest is _painful_ to remember,
> as the user just happened to be the vice president of the entire org. <g>

> Reason enough???

> I would suggest you use a VB app as a switchboard.

> < http://home.att.net/~dashish/modules/mdl0017.htm >

> HTH
> --
> Dev Ashish (Just my $.001)
> ---------------
> The Access Web ( http://home.att.net/~dashish )
> ---------------


> :Thanks...and a few SendKeys never hurt anyone   :)
> :
> :It works, but is there a way to prevent the "Open Database" dialog box from
> :appearing on the screen, or to make it invisible, or some other trick ?  It
> :looks a bit funny when it flashes on the screen even for half a second.
> :
> :By the way, the reason I want to do this is because I have 4 separate
> :database applications that I want to provide a front-end with 4 buttons,
> and
> :when the user selects a button then it opens that database.  You may say,
> :"why not just import everything into the 1 database?".  Well, I would, but
> :there is so much reused code in each, that it would step all over itself
> :without significant work.
> :
> :Thanks again.
> :
> :Rodney M. Gabriel
> :
> :************************************************************************

> :
> :> Hi Rodney,
> :>
> :> As I'd mentioned in my other post, this is not possible without using
> :> Sendkeys.
> :>
> :> < http://home.att.net/~dashish/modules/mdl0005.htm >
> :>
> :> HTH
> :> --
> :> Dev Ashish (Just my $.001)
> :> ---------------
> :> The Access Web ( http://home.att.net/~dashish )
> :> ---------------
> :>

> :> :I am trying to write code to close the currently open database (while
> :> :remaining in Access, connected to the current workgroup), and then
> :> :opening another database which uses the same workgroup.  I am trying to
> :> :use the code below, but it is not amused.  Does someone know how to fix
> :> :this ?  Thanks.
> :> :
> :> :*****************************************************************
> :> :  Rem ***** Declare local variables *****
> :> :
> :> :  Dim appAccess As Access.Application
> :> :  Dim strPath As String
> :> :  Dim strDatabase As String
> :> :
> :> :  Rem ***** Open database *****
> :> :
> :> :  strPath = CurDir
> :> :  strDatabase = strPath & "\another.mdb"
> :> :  appAccess.OpenCurrentDatabase strDatabase
> :> :
> :> :******************************************************************
> :> :Rodney M. Gabriel
> :> :
> :> :
> :



Fri, 17 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Well, the closing part isn't the problem; it's the opening part that doesn't
want to cooperate.

Rodney M. Gabriel

Quote:

> Why can't you have a function that counts the number of open objects and the
> issues a docmd.close for every open object?

> Randy


> >I am trying to write code to close the currently open database (while
> >remaining in Access, connected to the current workgroup), and then
> >opening another database which uses the same workgroup.  I am trying to
> >use the code below, but it is not amused.  Does someone know how to fix
> >this ?  Thanks.

> >*****************************************************************
> >  Rem ***** Declare local variables *****

> >  Dim appAccess As Access.Application
> >  Dim strPath As String
> >  Dim strDatabase As String

> >  Rem ***** Open database *****

> >  strPath = CurDir
> >  strDatabase = strPath & "\another.mdb"
> >  appAccess.OpenCurrentDatabase strDatabase

> >******************************************************************
> >Rodney M. Gabriel



Fri, 17 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
What about if I use "Shell" to start a new, separate instance of Access,
then use Application.Quit to quit the first instance ?  But in order to do
that and maintain security (without requiring them to login a second time)
I would need to pass the second instance 2 arguments --- the currentuser
(not a problem) and the current user's password.  Is that possible ?

The only other solution I can think of is to make the first database
"open", i.e. without a login, and then when they select another they login
to that one.  Problem with this is that everytime you want to go back to
the main screen you have to close Access and open the first instance.

Rodney M. Gabriel

Quote:

> I am trying to write code to close the currently open database (while
> remaining in Access, connected to the current workgroup), and then
> opening another database which uses the same workgroup.  I am trying to
> use the code below, but it is not amused.  Does someone know how to fix
> this ?  Thanks.

> *****************************************************************
>   Rem ***** Declare local variables *****

>   Dim appAccess As Access.Application
>   Dim strPath As String
>   Dim strDatabase As String

>   Rem ***** Open database *****

>   strPath = CurDir
>   strDatabase = strPath & "\another.mdb"
>   appAccess.OpenCurrentDatabase strDatabase

> ******************************************************************
> Rodney M. Gabriel



Mon, 27 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database

Quote:
> I would need to pass the second instance 2 arguments --- the currentuser
> (not a problem) and the current user's password.  Is that possible ?

No.  It's part of the Access security model that even a member of the
Admins group cannot ever see another user's password - the most that can
be done is to reset the password.

--
Paul Bredbury, http://dialspace.dial.pipex.com/brebs/



Tue, 28 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database

If you're comfortable with the idea of storing a user's name and password in a
secured table somewhere in your project,  you'd have the information you
need.You'd need a custom form for adding new users to the workgroup, and a
custom form for allowing users to change their passwords (good idea anyway, I
don't want my users having access to the security menu anyway)...these two
forms could do their business with the MDW file and then quietly store same
info in a table...


Quote:


>> I would need to pass the second instance 2 arguments --- the currentuser
>> (not a problem) and the current user's password.  Is that possible ?

>No.  It's part of the Access security model that even a member of the
>Admins group cannot ever see another user's password - the most that can
>be done is to reset the password.



Tue, 28 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database


Quote:

> If you're comfortable with the idea of storing a user's name and password in a
> secured table somewhere in your project,  you'd have the information you
> need.You'd need a custom form for adding new users to the workgroup, and a
> custom form for allowing users to change their passwords (good idea anyway, I
> don't want my users having access to the security menu anyway)...these two
> forms could do their business with the MDW file and then quietly store same
> info in a table...

The disadvantages I see to this are:

* It compromises the Access security model by allowing an Administrator
(i.e. a member of the Admins group) to impersonate any user whose
password is stored in the secure table.  I guess the significance of this
depends on how much you trust the Administrators <g>.

* You can't stop users from getting at the security menu, if they know
what they're doing with Access, and have the full version rather than
just Runtime.

* From the point above, you can't guarantee that the secure table is up-
to-date.

What we really need is a Gods user group, which would be more powerful
than the Admins group in that individual Gods would be able to see users'
passwords.  They could then argue amongst themselves about whether they
should be able to see each *other*'s passwords!

--
Paul Bredbury, http://dialspace.dial.pipex.com/brebs/



Tue, 28 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database

Quote:
>I would suggest you use a VB app as a switchboard.

How bout an all-code database as the switchboard app?


Fri, 31 Aug 2001 03:00:00 GMT  
 Close Database Then Open Database
Hi Carlo,

Too much overhead <g>

    -- Dev


t>...
:
:>I would suggest you use a VB app as a switchboard.
:
:
:How bout an all-code database as the switchboard app?
:
:



Mon, 03 Sep 2001 03:00:00 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. Close Database Then Open Database

2. Closing All Open Databases on Network

3. Database closes but Access 97 stays open

4. Open a second database and allow autoexec to run then close

5. Close Database Then Open Different Application

6. ADO Database connection open or closed?

7. opening/closing databases

8. Error 3043 - Database Open/Close procedures

9. When to open database and when to close?

10. Error 3043 - Database Open/Close procedures

11. Opening and closing database files using wildcards

12. When to open database and when to close?

 

 
Powered by phpBB® Forum Software