Syntax question

  • Thread starter Thread starter Parker
  • Start date Start date
P

Parker

I open a database from within access using this code:
Dim RetVal
RetVal = Shell("msaccess.exe C:\foldername\otherdatabase.mdb",
vbMaximizedFocus)

I need to use this code:

Dim RetVal
RetVal = Shell("msaccess.exe C:\folder name\otherdatabase.mdb",
vbMaximizedFocus)

The space in 'folder name' is causing problems. I've used the underscore key
and single quotes with no effect. What is the correct syntax.

Thanks
 
RetVal = Shell("msaccess.exe ""C:\folder name\otherdatabase.mdb""",
vbMaximizedFocus)

You may also have to provide a complete path to msaccess.exe, in which case
you'd need quotes there as well:

RetVal = Shell("""C:\Program Files\Microsoft Office\Office\msaccess.exe""
""C:\folder name\otherdatabase.mdb""", vbMaximizedFocus)
 
Thank you Doug.

Douglas J. Steele said:
RetVal = Shell("msaccess.exe ""C:\folder name\otherdatabase.mdb""",
vbMaximizedFocus)

You may also have to provide a complete path to msaccess.exe, in which
case you'd need quotes there as well:

RetVal = Shell("""C:\Program Files\Microsoft Office\Office\msaccess.exe""
""C:\folder name\otherdatabase.mdb""", vbMaximizedFocus)
 
Back
Top