Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Apostrophe in Comparison Field (2003)

    I suspect there is a simple solution, but I have yet to discover it. I have an update query where the fields used to "link" the tables periodically contains a single quote (apostrophe). Whenever this occurs the updated field results in a Null (or "#Error" if I use a select query using the following as the "field":

    DCount("YearCount","sqPreQry","Month([sqPreQry]![I_datInc])=1 and [PC]='" & [Name] & "'")

    Is there a way to code around instances where "[PC]" and/or "[Name]" contain a single quote?

    Thanks in advance for your ideas.

    Ken

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Apostrophe in Comparison Field (2003)

    If the values don't contain double quotes ", you can use
    <code>
    DCount("YearCount","sqPreQry","Month([sqPreQry]![I_datInc])=1 and [PC]=" & Chr(34) & [Name] & Chr(34))
    </code>
    See Chr() function and quotes within strings (all) for more info.

Posting Permissions

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