Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Dear Loungers,

    I have been converting my macros to vba. To do this I have used the Access conversion tool and then tidied things up. This is probably a dumb question I just can't find any one source that explain the possibilities... In some cases I am getting vba statement with multiple quotation marks and I don't now why, or if this is significant:

    • Example 1: TempVars.Add "tv_ErrorMessage", "[TempVars]![tv_ErrorMessage] & ""Event cannot be blank. """
      • in this case I can see how the last parameter has used quotation marks since the parameter is a string and that string is a concatenation of a the contents of the value of variable plus a text string; BUT as it stands [TempVars]![tv_ErrorMessage] won't resolve to the value of the variable so I am changing it to TempVars.Add "tv_ErrorMessage", [TempVars]![tv_ErrorMessage] & "Event cannot be blank."

      Example 2: TempVars.Add "tv_ErrorMessage", "[TempVars]![tv_ErrorMessage] & ""you must select an Item Type "" & Chr(10)"
      • this is similar to example 1 but the last parameter is a concatenation of value of variable plus a text string plus a line feed, in this case why is the ampersand concatenating the last element inside the quotation marks around the line feed?

      Example 3: TempVars.Add "tv_PER_Id", "Null"
      • This seem quite straightforward although since Null is a keyword I am surprised it was put in quotation marks, when I ran the code the string "null" was used rather than the value Null so have changed it and I am surprised the converter got this wrong.

      Example 4: TempVars.Add "tv_CurrentProcess", """Checkin"""
      • why is """Checkin""" using three pairs of quotation marks instead of one like this "Checkin" which seems to work fine?

      Example 5: DoCmd.OpenForm "frm_CheckIn1", acNormal, "", "", acAdd, acDialog
      • is leaving the parameter with nothing between the separating commas the same as using ""? so is this statement behave exactly the same way - DoCmd.OpenForm "frm_CheckIn1", acNormal, , , acAdd, acDialog - and must the separators have a space between them or does comma comma behave the same way as comma space comma?

    Can anyone explain what is happening and where I can find the general rules applying to the usage of quotation marks

    Many thanks..........................liz

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Example 5: DoCmd.OpenForm "frm_CheckIn1", acNormal, "", "", acAdd, acDialog
    • is leaving the parameter with nothing between the separating commas the same as using ""? so is this statement behave exactly the same way - DoCmd.OpenForm "frm_CheckIn1", acNormal, , , acAdd, acDialog -
    Yes the two statements are the same.
    and must the separators have a space between them or does comma comma behave the same way as comma space comma?
    If you put in the separators without a space between them, Access will automatically put in a space.
    If you put in "" Access will put a space in front of the ""

    I won't comment on the others, as I have never used TempVars. To me they all seem to have too many double quotes.
    When I search VBA Help on TempVars I am told to check my spelling and try again!

    I general you leave Variable Names outside the double quotes so that it is the value of the variable that is used , rather than the variable name.
    Regards
    John



  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Liz & John,

    I've never used TempVars either so I googled it and found this on the Microsoft Office site. It's new to 2007.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •