Results 1 to 7 of 7
  1. #1
    ybg1 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    23

    Using IN Syntax in a Filter

    Hello there!



    The following code works fine

    G_StrWhere = "[Group]=" & G_Group_Code & " AND " & "[EntryDate]=" & SQLDate(G_Greg_Date)

    Me.Filter = G_StrWhere
    Me.FilterOn = True

    I would like to get 2 Groups together in the first part using the syntax " IN"
    e.g. (4,6 IN G_Group_Code)
    Anyone knows how to do it?

    Thanks


  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    No, I don't know offhand.

    Have you tried to construct the query through query design and then abstract the SQL to the filter?

  3. #3
    ybg1 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    23

    Using IN Syntax in a Filter

    The answer is -

    "[Group] IN(4,6)" & " AND " & "[EntryDate]=" & SQLDate(G_Greg_Date)

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by ybg1 View Post
    The answer is -

    "[Group] IN(4,6)" & " AND " & "[EntryDate]=" & SQLDate(G_Greg_Date)
    No need for the extra ampersands and quotes. This would be fine:


    "[Group] IN(4,6) AND [EntryDate]=" & SQLDate(G_Greg_Date)

    Keep the extraneous stuff out of there (keep it as simple as possible).

  5. #5
    ybg1 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    23

    Using IN Syntax in a Filter

    Thank you for your suggestion:
    "No need for the extra ampersands and quotes"
    I've Kept the extraneous stuff out of there and it works fine.

    What I should remove from the following so I wouldn't have extraneous stuff ?

    StrWhere = "[Group]=" & G_Group_Code & " AND " & "[EntryDate]=" & SQLDate(G_Greg_Date)

    Thanks

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    StrWhere = "[Group]=" & G_Group_Code & " AND [EntryDate]=" & SQLDate(G_Greg_Date)

  7. #7
    ybg1 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    23
    Perfect.

    Thanks alot

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

Similar Threads

  1. Help with syntax
    By accesskid in forum Forms
    Replies: 3
    Last Post: 06-02-2011, 05:14 AM
  2. Slow response over VPN or To Filter or not To Filter
    By rcrobman in forum Database Design
    Replies: 0
    Last Post: 04-30-2011, 02:37 PM
  3. Syntax Error in Query Expression on filter
    By alaric01 in forum Forms
    Replies: 1
    Last Post: 10-14-2010, 07:23 AM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Please help SQL Syntax
    By jordanturner in forum Access
    Replies: 4
    Last Post: 09-02-2010, 08:05 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