Syntax question

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
 
D

Douglas J. Steele

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)
 
P

Parker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top