A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Command button to open another database?



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2008, 08:42 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default Command button to open another database?

I have a command button on a form that opens another form within the same
database. Is it possible to have one that opens a separate database? Right
now my code for the former is:

Private Sub GoToCMLabels_Click()
DoCmd.OpenForm "frmCMLabelsDataEntry", acNormal, "", "", , acNormal
DoCmd.Close acForm, "frmCMDMSearch"

End Sub

If possible, what would the code look like to open a separate DB?

--
GD
  #2  
Old December 18th, 2008, 09:08 PM posted to microsoft.public.access.gettingstarted
Ed Robichaud
external usenet poster
 
Posts: 90
Default Command button to open another database?

Access can only have one database open at a time, though you can be linked
simultaneously to many data files. You can however program a command button
to open another instance of Access to show your other database.

You can use the command button wizard to generate code similar to below:

Private Sub btnOtherDB_Click()
On Error GoTo Err_btnOtherDB_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE
FullPathName\MyApp.mdb"
Call Shell(stAppName, 1)

Exit_btnOtherDB_Click:
Exit Sub

Err_btnOtherDB_Click:
MsgBox Err.Description
Resume Exit_btnOtherDB_Click
End Sub


-Ed



"GD" wrote in message
...
I have a command button on a form that opens another form within the same
database. Is it possible to have one that opens a separate database?
Right
now my code for the former is:

Private Sub GoToCMLabels_Click()
DoCmd.OpenForm "frmCMLabelsDataEntry", acNormal, "", "", , acNormal
DoCmd.Close acForm, "frmCMDMSearch"

End Sub

If possible, what would the code look like to open a separate DB?

--
GD



  #3  
Old December 19th, 2008, 01:17 AM posted to microsoft.public.access.gettingstarted
Kevbro7189
external usenet poster
 
Posts: 35
Default Command button to open another database?

2007 Can have two DB open at once, I’m not sure about the others. The
easiest way I have found to do this with a button is to use a Macro with the
ACTION (RunApp) and the COMAND LINE something like ("C:\Program
Files\Microsoft Office\OFFICE12\Access.EXE" "C:\File\AccessFileName.mdb")

The file locations will change.
Make sure you use the quotes.

Hope this helps
Kevbro

"Ed Robichaud" wrote:

Access can only have one database open at a time, though you can be linked
simultaneously to many data files. You can however program a command button
to open another instance of Access to show your other database.

You can use the command button wizard to generate code similar to below:

Private Sub btnOtherDB_Click()
On Error GoTo Err_btnOtherDB_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE
FullPathName\MyApp.mdb"
Call Shell(stAppName, 1)

Exit_btnOtherDB_Click:
Exit Sub

Err_btnOtherDB_Click:
MsgBox Err.Description
Resume Exit_btnOtherDB_Click
End Sub


-Ed



"GD" wrote in message
...
I have a command button on a form that opens another form within the same
database. Is it possible to have one that opens a separate database?
Right
now my code for the former is:

Private Sub GoToCMLabels_Click()
DoCmd.OpenForm "frmCMLabelsDataEntry", acNormal, "", "", , acNormal
DoCmd.Close acForm, "frmCMDMSearch"

End Sub

If possible, what would the code look like to open a separate DB?

--
GD




  #4  
Old December 19th, 2008, 01:45 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default Command button to open another database?

Hey Ed. Your solution works great, but I'm running into a problem because
one of the subfolders I have to use to get to the new DB has a space in it.
Is there a way to alter the code to account for that? I don't have the
option of changing the folder name.

--
GD


"Ed Robichaud" wrote:

Access can only have one database open at a time, though you can be linked
simultaneously to many data files. You can however program a command button
to open another instance of Access to show your other database.

You can use the command button wizard to generate code similar to below:

Private Sub btnOtherDB_Click()
On Error GoTo Err_btnOtherDB_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE
FullPathName\MyApp.mdb"
Call Shell(stAppName, 1)

Exit_btnOtherDB_Click:
Exit Sub

Err_btnOtherDB_Click:
MsgBox Err.Description
Resume Exit_btnOtherDB_Click
End Sub


-Ed



"GD" wrote in message
...
I have a command button on a form that opens another form within the same
database. Is it possible to have one that opens a separate database?
Right
now my code for the former is:

Private Sub GoToCMLabels_Click()
DoCmd.OpenForm "frmCMLabelsDataEntry", acNormal, "", "", , acNormal
DoCmd.Close acForm, "frmCMDMSearch"

End Sub

If possible, what would the code look like to open a separate DB?

--
GD




  #5  
Old December 19th, 2008, 03:36 PM posted to microsoft.public.access.gettingstarted
Ed Robichaud
external usenet poster
 
Posts: 90
Default Command button to open another database?

Just enclose the folder/file name in double quotes ("xx").



"GD" wrote in message
...
Hey Ed. Your solution works great, but I'm running into a problem because
one of the subfolders I have to use to get to the new DB has a space in
it.
Is there a way to alter the code to account for that? I don't have the
option of changing the folder name.

--
GD


"Ed Robichaud" wrote:

Access can only have one database open at a time, though you can be
linked
simultaneously to many data files. You can however program a command
button
to open another instance of Access to show your other database.

You can use the command button wizard to generate code similar to below:

Private Sub btnOtherDB_Click()
On Error GoTo Err_btnOtherDB_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE
FullPathName\MyApp.mdb"
Call Shell(stAppName, 1)

Exit_btnOtherDB_Click:
Exit Sub

Err_btnOtherDB_Click:
MsgBox Err.Description
Resume Exit_btnOtherDB_Click
End Sub


-Ed



"GD" wrote in message
...
I have a command button on a form that opens another form within the
same
database. Is it possible to have one that opens a separate database?
Right
now my code for the former is:

Private Sub GoToCMLabels_Click()
DoCmd.OpenForm "frmCMLabelsDataEntry", acNormal, "", "", , acNormal
DoCmd.Close acForm, "frmCMDMSearch"

End Sub

If possible, what would the code look like to open a separate DB?

--
GD






  #6  
Old December 19th, 2008, 03:43 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default Command button to open another database?

Awesome! Thanks again, Ed.
--
GD


"Ed Robichaud" wrote:

Just enclose the folder/file name in double quotes ("xx").



"GD" wrote in message
...
Hey Ed. Your solution works great, but I'm running into a problem because
one of the subfolders I have to use to get to the new DB has a space in
it.
Is there a way to alter the code to account for that? I don't have the
option of changing the folder name.

--
GD


"Ed Robichaud" wrote:

Access can only have one database open at a time, though you can be
linked
simultaneously to many data files. You can however program a command
button
to open another instance of Access to show your other database.

You can use the command button wizard to generate code similar to below:

Private Sub btnOtherDB_Click()
On Error GoTo Err_btnOtherDB_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE
FullPathName\MyApp.mdb"
Call Shell(stAppName, 1)

Exit_btnOtherDB_Click:
Exit Sub

Err_btnOtherDB_Click:
MsgBox Err.Description
Resume Exit_btnOtherDB_Click
End Sub


-Ed



"GD" wrote in message
...
I have a command button on a form that opens another form within the
same
database. Is it possible to have one that opens a separate database?
Right
now my code for the former is:

Private Sub GoToCMLabels_Click()
DoCmd.OpenForm "frmCMLabelsDataEntry", acNormal, "", "", , acNormal
DoCmd.Close acForm, "frmCMDMSearch"

End Sub

If possible, what would the code look like to open a separate DB?

--
GD






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.