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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|