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  

Meddlesome space within folder name in code



 
 
Thread Tools Display Modes
  #1  
Old December 19th, 2008, 01:59 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default Meddlesome space within folder name in code

I thought this question was answered, but apparently not. I have a command
button on a form to open a new database, but the space between Ken & Smith in
the code below is preventing the DB from opening.

Private Sub cmdGoToPaybacks_Click()
On Error GoTo Err_cmdGoToPaybacks_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb"
Call Shell(stAppName, 1)

Exit_cmdGoToPaybacks_Click:
Exit Sub

Err_cmdGoToPaybacks_Click:
MsgBox Err.Description
Resume Exit_cmdGoToPaybacks_Click

End Sub

The warning I get is "MicroSoft Office Access can't find the database file
'S:\Finance\FinCommon\Ken.mdb'

Is there a way to account for the space in code? I don't have the option of
changing the folder name.

--
GD


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



  #2  
Old December 19th, 2008, 02:41 PM posted to microsoft.public.access.gettingstarted
Dorian
external usenet poster
 
Posts: 542
Default Meddlesome space within folder name in code

Are you sure you have the S: drive mapped?
Its best to refer to the server directly e.g.
\\server-name\folder1\folder2
since different users may have their drivesd mapped differently.
Your path should be ok provided you place it in quotes, try putting single
quotes around the path:
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
'S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb'"
or maybe doubled up double quotes:
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
""S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb"""

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"GD" wrote:

I thought this question was answered, but apparently not. I have a command
button on a form to open a new database, but the space between Ken & Smith in
the code below is preventing the DB from opening.

Private Sub cmdGoToPaybacks_Click()
On Error GoTo Err_cmdGoToPaybacks_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb"
Call Shell(stAppName, 1)

Exit_cmdGoToPaybacks_Click:
Exit Sub

Err_cmdGoToPaybacks_Click:
MsgBox Err.Description
Resume Exit_cmdGoToPaybacks_Click

End Sub

The warning I get is "MicroSoft Office Access can't find the database file
'S:\Finance\FinCommon\Ken.mdb'

Is there a way to account for the space in code? I don't have the option of
changing the folder name.

--
GD


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, 02:47 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default Meddlesome space within folder name in code

Thanks, Dorian! The "" works great. Have a great holiday!
--
GD


"Dorian" wrote:

Are you sure you have the S: drive mapped?
Its best to refer to the server directly e.g.
\\server-name\folder1\folder2
since different users may have their drivesd mapped differently.
Your path should be ok provided you place it in quotes, try putting single
quotes around the path:
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
'S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb'"
or maybe doubled up double quotes:
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
""S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb"""

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"GD" wrote:

I thought this question was answered, but apparently not. I have a command
button on a form to open a new database, but the space between Ken & Smith in
the code below is preventing the DB from opening.

Private Sub cmdGoToPaybacks_Click()
On Error GoTo Err_cmdGoToPaybacks_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb"
Call Shell(stAppName, 1)

Exit_cmdGoToPaybacks_Click:
Exit Sub

Err_cmdGoToPaybacks_Click:
MsgBox Err.Description
Resume Exit_cmdGoToPaybacks_Click

End Sub

The warning I get is "MicroSoft Office Access can't find the database file
'S:\Finance\FinCommon\Ken.mdb'

Is there a way to account for the space in code? I don't have the option of
changing the folder name.

--
GD


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 20th, 2008, 11:07 PM posted to microsoft.public.access.gettingstarted
Clifford Bass[_2_]
external usenet poster
 
Posts: 1,295
Default Meddlesome space within folder name in code

Hi,

Note that hard coding the path to MSACCESS.EXE is not advisable.
People can customize where to install and may have different versions than
the one you are coding. Better to use SysCmd(acSysCmdAccessDir) &
"MSACCESS.EXE ""S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb""".

Clifford Bass


"GD" wrote:

I thought this question was answered, but apparently not. I have a command
button on a form to open a new database, but the space between Ken & Smith in
the code below is preventing the DB from opening.

Private Sub cmdGoToPaybacks_Click()
On Error GoTo Err_cmdGoToPaybacks_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
S:\Finance\FinCommon\Ken Smith\Paybacks\Paybacks.mdb"
Call Shell(stAppName, 1)

Exit_cmdGoToPaybacks_Click:
Exit Sub

Err_cmdGoToPaybacks_Click:
MsgBox Err.Description
Resume Exit_cmdGoToPaybacks_Click

End Sub

The warning I get is "MicroSoft Office Access can't find the database file
'S:\Finance\FinCommon\Ken.mdb'

Is there a way to account for the space in code? I don't have the option of
changing the folder name.

--
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 08:10 AM.


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