Results 1 to 8 of 8
  1. #1
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265

    I can't understand the double and single quotations in this code

    Please see the attached Word file for a screen shot. This is a screen shot from a DVD tutorial I am watching. I am only concerned about the quotes in the red box. In my opinion, the person doesn't do an adequate job of explaining the purpose of the double and single quotes. I understand it, then I don't. Perhaps if he typed all the text first, then went back and placed the quotations, this would be much easier to understand.



    This is driving me crazy.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The WHERE CONDITION of OpenForm (or OpenReport) follows syntax of query WHERE clause.

    The apostrophes delimit a text criteria, # is for date criteria, nothing for number.

    "DateEnter = #" & Me.SearchDate & "#"

    "ID = " & Me.SearchNumber

    The quotes tell VBA the beginning and end of a text string.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    First question is what do you mean when you say an apostrophe delimits a text criteria?

    Secondly, if you look at the quotes in my screen shot, I can you explain which chunk of data is enclosed in first ", the second ", the third ", the fourth ", and the first and second '. This would make it much easier for me to see what section of the code each set of " and ' corresponds to.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Quotes and apostrophes would be in pairs. Quotes are the outer pair and apostrophes are inner. So start from the left. Look at examples with literal criteria, not concatenated variable.

    "ItemTitle Like 'Little*'"

    "ItemDate = #1/1/2013#"

    "ItemID = 15"

    Now concatenating a variable in place of the literal.

    "ItemTitle Like '" & Me.Search & "*'"

    "ItemDate = #" & Me.Search & "#"

    "ItemID = " & Me.Search

    This doesn't take into account apostrophes used in data - that's another issue. Like street names with possessive - Adam's Blvd. And quote marks in data is a real nuisance.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    I think I understand what you are saying,, but I can't apply that to my example. I have another attachment with three possible ways of seeing the grouping of the quotes in question. The attached file is called "3 Possibilities."

    Can you tell me which of the three is correct? I'm still failing to see grouping.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Look at my examples that use literal criteria and do not have concatenation.

    Everything within two quote marks is a discrete string, starting from the leftmost, then the ' and # delimiters define text and date criteria.

    Imagine how string built by an expression using concatenation will look after code executes. It should be a string like the literal examples.

    Therefore the middle example is correct.

    Review link on debugging techniques at bottom of my post. There are methods to help you analyse if the concatenation is correct.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Quote Originally Posted by June7 View Post
    Look at my examples that use literal criteria and do not have concatenation.

    Everything within two quote marks is a discrete string, starting from the leftmost, then the ' and # delimiters define text and date criteria.

    Imagine how string built by an expression using concatenation will look after code executes. It should be a string like the literal examples.

    Therefore the middle example is correct.

    Review link on debugging techniques at bottom of my post. There are methods to help you analyse if the concatenation is correct.
    I've got it now. The part that was throwing me off in my example were the " surrounding the me.search and the &. Thank you for your insight.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That's because the " marks aren't surrounding the Me.Search and the &s, those are outside the paired " marks.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Single and double quotes in a INSERT statement
    By dccjr in forum Programming
    Replies: 16
    Last Post: 03-14-2013, 09:50 PM
  2. Help with quotations in DLookup
    By kenton.l.sparks@gmail.com in forum Access
    Replies: 1
    Last Post: 10-15-2012, 12:37 AM
  3. Help me understand queries in my code
    By Datech in forum Queries
    Replies: 0
    Last Post: 06-15-2012, 08:32 PM
  4. Need to understand code
    By accessnewb in forum Programming
    Replies: 2
    Last Post: 08-03-2011, 12:03 PM
  5. Quotations Database
    By Kari-z in forum Database Design
    Replies: 2
    Last Post: 01-26-2011, 09:03 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums