Opening different database 
Author Message
 Opening different database

I am trying to open another database and close the current one from a
switchboard button. I have searched the newsgroup and found this code:

    Dim lRetVal As Long
    lRetVal = Shell("msaccess.exe C:\TheOtherFile.mdb")
    Application.Quit

I have built a function that returns the current path of the database but I
can't plug it into the shell command and make it run properly. What I've
tried is:
    Shell("msaccess.exe" & CurrentDBDir() & "TheOtherFile.mdb"). But when
this runs it tells me I have used an improper command line option and then a
second screen shows me it was trying to open a file called C:/My.mdb.

Can anyone give me suggestions on how to parse this data together and get it
to run. the Function "CurrentDBDir" returns the full path of the current
database and where my other database is also located = the string begins
with the Drive letter and ends with "\"

My intention is to use a menu button to switch to the 2nd database and close
the current one and vice-versa in the other. I prefer not to leave both open
at the same time.

Thanks for any help you can offer

Paul P



Mon, 20 Jun 2005 12:19:36 GMT  
 Opening different database
Try

    Shell "msaccess.exe " & _
        Chr(34)  & CurrentDBDir() & "TheOtherFile.mdb" & Chr(34)

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Quote:
> I am trying to open another database and close the current one from
a
> switchboard button. I have searched the newsgroup and found this
code:

>     Dim lRetVal As Long
>     lRetVal = Shell("msaccess.exe C:\TheOtherFile.mdb")
>     Application.Quit

> I have built a function that returns the current path of the
database but I
> can't plug it into the shell command and make it run properly. What
I've
> tried is:
>     Shell("msaccess.exe" & CurrentDBDir() & "TheOtherFile.mdb"). But
when
> this runs it tells me I have used an improper command line option
and then a
> second screen shows me it was trying to open a file called
C:/My.mdb.

> Can anyone give me suggestions on how to parse this data together
and get it
> to run. the Function "CurrentDBDir" returns the full path of the
current
> database and where my other database is also located = the string
begins
> with the Drive letter and ends with "\"

> My intention is to use a menu button to switch to the 2nd database
and close
> the current one and vice-versa in the other. I prefer not to leave
both open
> at the same time.

> Thanks for any help you can offer

> Paul P



Mon, 20 Jun 2005 12:27:17 GMT  
 Opening different database
Actually, unless msaccess.exe is located in a folder that's included in the
PATH environment variable, I believe you have to give a full path to where
it's located.

Fortunately, this is relatively easy: SysCmd(acSysCmdAccessDir) will return
that information.

     Shell Chr$(34) & SysCmd(acSysCmdAccessDir) & _
         "msaccess.exe" & Chr$(34) & " " _
         Chr$(34)  & CurrentDBDir() & _
         "TheOtherFile.mdb" & Chr$(34)

Don't forget the space between the executable name and the database name.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele


Quote:
> Try

>     Shell "msaccess.exe " & _
>         Chr(34)  & CurrentDBDir() & "TheOtherFile.mdb" & Chr(34)

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > I am trying to open another database and close the current one from
> a
> > switchboard button. I have searched the newsgroup and found this
> code:

> >     Dim lRetVal As Long
> >     lRetVal = Shell("msaccess.exe C:\TheOtherFile.mdb")
> >     Application.Quit

> > I have built a function that returns the current path of the
> database but I
> > can't plug it into the shell command and make it run properly. What
> I've
> > tried is:
> >     Shell("msaccess.exe" & CurrentDBDir() & "TheOtherFile.mdb"). But
> when
> > this runs it tells me I have used an improper command line option
> and then a
> > second screen shows me it was trying to open a file called
> C:/My.mdb.

> > Can anyone give me suggestions on how to parse this data together
> and get it
> > to run. the Function "CurrentDBDir" returns the full path of the
> current
> > database and where my other database is also located = the string
> begins
> > with the Drive letter and ends with "\"

> > My intention is to use a menu button to switch to the 2nd database
> and close
> > the current one and vice-versa in the other. I prefer not to leave
> both open
> > at the same time.

> > Thanks for any help you can offer

> > Paul P



Mon, 20 Jun 2005 20:06:48 GMT  
 Opening different database
True, though I read Mr. Proefrock's post as saying that Access did in
fact open, but didn't understand the DB name.

As an alternative, one could use MichKa's TSI SOON (Shut One, Open
New) add-in:

    http://www.trigeminal.com/lang/1033/utility.asp?ItemID=8#8

That's what I'd do.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Quote:
> Actually, unless msaccess.exe is located in a folder that's included
in the
> PATH environment variable, I believe you have to give a full path to
where
> it's located.

> Fortunately, this is relatively easy: SysCmd(acSysCmdAccessDir) will
return
> that information.

>      Shell Chr$(34) & SysCmd(acSysCmdAccessDir) & _
>          "msaccess.exe" & Chr$(34) & " " _
>          Chr$(34)  & CurrentDBDir() & _
>          "TheOtherFile.mdb" & Chr$(34)

> Don't forget the space between the executable name and the database
name.

> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele



> > Try

> >     Shell "msaccess.exe " & _
> >         Chr(34)  & CurrentDBDir() & "TheOtherFile.mdb" & Chr(34)

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



> > > I am trying to open another database and close the current one
from
> > a
> > > switchboard button. I have searched the newsgroup and found this
> > code:

> > >     Dim lRetVal As Long
> > >     lRetVal = Shell("msaccess.exe C:\TheOtherFile.mdb")
> > >     Application.Quit

> > > I have built a function that returns the current path of the
> > database but I
> > > can't plug it into the shell command and make it run properly.
What
> > I've
> > > tried is:
> > >     Shell("msaccess.exe" & CurrentDBDir() & "TheOtherFile.mdb").
But
> > when
> > > this runs it tells me I have used an improper command line
option
> > and then a
> > > second screen shows me it was trying to open a file called
> > C:/My.mdb.

> > > Can anyone give me suggestions on how to parse this data
together
> > and get it
> > > to run. the Function "CurrentDBDir" returns the full path of the
> > current
> > > database and where my other database is also located = the
string
> > begins
> > > with the Drive letter and ends with "\"

> > > My intention is to use a menu button to switch to the 2nd
database
> > and close
> > > the current one and vice-versa in the other. I prefer not to
leave
> > both open
> > > at the same time.

> > > Thanks for any help you can offer

> > > Paul P



Tue, 21 Jun 2005 01:19:31 GMT  
 Opening different database
Thanks, guys, that solved the problem.

Paul P

Quote:
> Try

>     Shell "msaccess.exe " & _
>         Chr(34)  & CurrentDBDir() & "TheOtherFile.mdb" & Chr(34)

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > I am trying to open another database and close the current one from
> a
> > switchboard button. I have searched the newsgroup and found this
> code:

> >     Dim lRetVal As Long
> >     lRetVal = Shell("msaccess.exe C:\TheOtherFile.mdb")
> >     Application.Quit

> > I have built a function that returns the current path of the
> database but I
> > can't plug it into the shell command and make it run properly. What
> I've
> > tried is:
> >     Shell("msaccess.exe" & CurrentDBDir() & "TheOtherFile.mdb"). But
> when
> > this runs it tells me I have used an improper command line option
> and then a
> > second screen shows me it was trying to open a file called
> C:/My.mdb.

> > Can anyone give me suggestions on how to parse this data together
> and get it
> > to run. the Function "CurrentDBDir" returns the full path of the
> current
> > database and where my other database is also located = the string
> begins
> > with the Drive letter and ends with "\"

> > My intention is to use a menu button to switch to the 2nd database
> and close
> > the current one and vice-versa in the other. I prefer not to leave
> both open
> > at the same time.

> > Thanks for any help you can offer

> > Paul P



Tue, 21 Jun 2005 08:56:18 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Open different database file within Access using code

2. Opening different databases/user

3. !!! Help !!! SwitchBoard to Open Different Databases !!! Help !!!

4. Close Database Then Open Different Application

5. How to Open a different Database File Whithin another

6. Open database from VBA with different workgroup.

7. Opening a different database

8. Opening different DBASE-Databases at runtime via DAO

9. Open Two Database with Two System.Mda and Two different User Names and Password

10. Launching a different database from a different db w/ vba

11. Repointing a database control to a different database

12. Open another database and keep existing one open

 

 
Powered by phpBB® Forum Software