Results 1 to 4 of 4
  1. #1
    RonL is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Location
    NJ
    Posts
    114

    .findFirst 3077 syntax error

    Hello. I'm trying to use the following statement with a (temporarily defined) recordset. I keep getting the 3077 error: "syntax error in string," no matter how I try to rearrange the quote marks. What's the proper syntax?

    Code:
    with myRecordset
    .FindFirst "[ShotNumSuffix] = " & Nz(varShotNumSuffix, " ") & "
    The field is typed as a string, but may be null.



    varShotNumSuffix is typed as a string, but may be null. If it is null, I want to set ShotNumSuffix to
    a zero length string (but leave it alone if it has some alphabetic value). However, even when I take precaution of first setting both the field and the variable to " ", I'm still getting
    the error. This is probably a newbie quote mark issue, but keeps hanging me up.

    Thanks for any help.

    -Ron

    Edit - I'm aware that the definition of the NZ function prescribes that the variable should be typed as variant. Is that literally mandatory, or does it mean the variable could be any type? Pretty sure I've seen it used for string variables.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Try


    .FindFirst "[ShotNumSuffix] = '" & Nz(varShotNumSuffix, " ") & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RonL is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Location
    NJ
    Posts
    114
    Yup, that works. Thank you pbaldy! One of these days I'll stop making this mistake....

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  2. Findfirst syntax problem
    By tarenja in forum Programming
    Replies: 2
    Last Post: 08-08-2013, 05:30 AM
  3. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. using FindFirst with a Date Criteria (syntax error)
    By ajetrumpet in forum Programming
    Replies: 2
    Last Post: 09-10-2010, 11:01 PM

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