Correct syntax in some strPath code?

G

Guest

I have created a command button on our forms that creates (on first click)
and then subsequently (on later clicks) takes us into a folder on the server
where we can save and then access various documents associated with our
transactions.

At present the new folder name consists of the job Ref and the customer's
Surname. So a typical folder would be named ....\70301Smith.

The line that deals with this is:
strPath = "\\Server1\Docs\" & Me.Ref & Me.Customer1Surname

This is OK and working fine except that we would like to have a space
between the Ref and the Surname, i.e. \70301 Smith, as the name is then
easier to see at glance.

But I can't work out how to force a space, i.e. how the last bit of the
strPath code should be written. I have tried a space, a hyphen, an
underscore, and VB doesn't like any of those.

No doubt this is another of those "easy when you know how" issues ... please
let me into the secret!
Many thanks
CW
 
D

Douglas J. Steele

strPath = """\\Server1\Docs\" & Me.Ref & Me.Customer1Surname & """"

or

strPath = Chr$(34) & "\\Server1\Docs\" & Me.Ref & Me.Customer1Surname &
Chr$(34)

(Watch for word-wrap: the second alternative is also supposed to be on one
line. And just to be explicit, in the first alternative, that's 3 double
quotes at the beginning, and 4 double quotes at the end.)
 
D

Douglas J. Steele

Ooops, missed the space!

strPath = """\\Server1\Docs\" & Me.Ref & _
" " & Me.Customer1Surname & """"

or

strPath = Chr$(34) & "\\Server1\Docs\" & _
Me.Ref & " " & Me.Customer1Surname & _
Chr$(34)
 

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