Fix my shell

G

Guest

This syntax confuses me. I have a form with the field value
'C:/filename.mdb' that I want to open a new instance of Access using that
file:

strFileName = Me.FileName.Value

Select Case strCboValue
Case "Open"
Shell """c:\program files\microsoft office\office11\msaccess.exe""
strFileName", vbMaximizedFocus
Etc...

I've tried variations but can't get it to open up the mdb file. Thanks
 
D

Dirk Goldgar

In
Maarkr said:
This syntax confuses me. I have a form with the field value
'C:/filename.mdb' that I want to open a new instance of Access using
that file:

strFileName = Me.FileName.Value

Select Case strCboValue
Case "Open"
Shell """c:\program files\microsoft
office\office11\msaccess.exe"" strFileName", vbMaximizedFocus
Etc...

I've tried variations but can't get it to open up the mdb file.
Thanks

First, check your file path. You wrote (above):

'C:/filename.mdb'

but the forward-slash should be a back-slash. Odds are, that's just an
error in your post, not your code.

The main problem appears to be that you have the variable name inside
the quotes. Try this version, reorganized to make the quoting a bit
clearer:

Const Q As String = """"

Shell _
Q & _
"c:\program files\microsoft office\office11\msaccess.exe" &
_
Q & _
" " & _
Q & _
strFileName & _
Q, _
vbMaximizedFocus

I added quotes around strFileName, too, in case that might happen to
have an embedded space.
 
G

Guest

Instead of shelling out to Access application, consider using the
FollowHyperlink method of the Application. It would look something like:

Application.followhyperlink me.filename.value

HTH
Dale
 

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