Problem going to external folder

C

CW

This is rather a lengthy one...I will try to be clear...
To handle our jobs I have a Main form and 5 subforms on tabs.
Each job is identified by Ref and Surname.
The parent-child link on all forms is Ref-Ref.
Using some code that some kind soul suggested a few months ago, we can
create and subsequently access a folder elsewhere on the network (it's I:\07
Ref Number) to store all the documents and emails and whatever else, relating
to each job. That code is as follows:


Private Sub GoToFolder_Click()
Dim strPath As String

strPath = "I:\07 Ref Number\" & Me.Ref & Me.Surname
If Len(Dir(strPath, vbDirectory)) = 0 Then
MkDir strPath
End If
Shell "explorer.exe " & strPath, vbNormalFocus

End Sub

This (a Folder command button) has been working fine on the Main form and
users wanted it deployed on all the tabbed forms too, so I added it. It works
fine on two of them, but not on the other three!!! When the Folder button
is clicked it produces a VB Compile Error, "Method or data member not found",
and highlights Me.Ref on the third line of code as the problem area.
I have checked the Properties and relationships and links, compared them
minutely with working forms and non-working forms, everything I can think of,
but to no avail!!
Any brainwave suggestions would be VERY much appreciated!!
Many thanks
CW
 
D

Douglas J. Steele

The fact that the path includes spaces means you need to put quotes around
it.

Try:

Shell "explorer.exe " & Chr$(34) & strPath & Chr$(34), vbNormalFocus

or

Shell "explorer.exe """ & strPath & """", vbNormalFocus

(That's 3 double quotes before, and 4 double quotes after)
 

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