Results 1 to 4 of 4
  1. #1
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122

    Help figure out what's wrong with this syntax

    All,


    I am just a beginning with VBScript in Access. I am sure it will be very easy for you to spot what I did wrong below. I am trying to filter "Referrals" where Payors appears in a multiple search list, as well as DeclineReasons in a multiple search list PLUS the PCriterias, which is a bunch of other fields. Ty for your help in advance.

    Task = "select * from Referrals where ([Payor] in (" & StrSearch & ") & [DeclineReasons] in (" & StrSearch2 & "))" & " AND " & PCriteria


    Sincerely,
    Perry

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Use AND in place of the & character in front of [DeclineReasons].

    Task = "SELECT * FROM Referrals WHERE ([Payor] IN (" & StrSearch & ") AND [DeclineReasons] IN (" & StrSearch2 & ")) AND " & PCriteria
    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
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    Try adding a debug.Print Task - to see what the sql resolves to. Should help you to see whats wrong.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    June7, ty, as easy as that! and ty for the tip, Moke123 as well.

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

Similar Threads

  1. Can't figure out the syntax error
    By bubai in forum Programming
    Replies: 6
    Last Post: 11-23-2021, 11:22 AM
  2. Can't figure out where I am going wrong
    By sknechte in forum Queries
    Replies: 3
    Last Post: 02-04-2018, 03:25 PM
  3. Replies: 13
    Last Post: 04-17-2013, 04:17 PM
  4. Date Syntax in vba is wrong ?
    By burrina in forum Forms
    Replies: 3
    Last Post: 02-20-2013, 12:34 AM
  5. can't figure out what i'm doing wrong
    By m0use in forum Queries
    Replies: 4
    Last Post: 06-16-2011, 09:18 AM

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