• Significance of quotation marks and syntax

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Significance of quotation marks and syntax

    Author
    Topic
    #472426

    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?

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

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

    Viewing 1 reply thread
    Author
    Replies
    • #1250746

      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.

    • #1250775

      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!
      Computer Specs

    Viewing 1 reply thread
    Reply To: Significance of quotation marks and syntax

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: