How to get quotes wrapped around my variable when constructing an output variable.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ncsthbell
    New Member
    • May 2007
    • 167

    How to get quotes wrapped around my variable when constructing an output variable.

    I am trying to construct a 'Copy' statement in Access 2000 vb that I will actually write out to create a .bat file. My problem is that I need to put quotes around the vcFileFrom and vcFileTo (“vcFileFro m” and “vcFileTo” ) to be able to handle having spaces in the file name. I just can not seem to get the correct syntax in my access vb code to get the quotes around the filenames.

    I have the following code:

    OutRec = "Copy " & vcFileFrom & ", " & vcFileTo & ""

    The result of this is:

    OutRec = Copy C:\Data\From\DB .mdb, U:\Data\TO\DB.m db

    What I need the results to be is:

    OutRec = Copy “C:\Data\F rom\D B.mdb”, “U:\Data\T O\D B.mdb”

    (having the space in the .mdb name).

    The first copy statement works as long as my file name does not contain any spaces. So, I am trying to change the copy statement to be able to handle files with spaces.
    Can anyone tell me how to get the quotes wrapped around my “FromFile” and “ToFile” variables when trying to build the syntax? I’ve tried several ways and cannot get it to work.

    Thanks!
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    Two quotes in your string will evaluate to one quote.
    Code:
    OutRec = "Copy """ & vcFileFrom & """, """ & vcFileTo & """"

    Comment

    • ncsthbell
      New Member
      • May 2007
      • 167

      #3
      OMG!! This worked perfectly! I don't know why I have struggled so much to get this seemingly simple thing done.... however, thanks so much for your help!

      Comment

      Working...