Fix my shell

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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
 
Back
Top