DCount syntax error when using WHERE...IN

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muse79
    New Member
    • May 2015
    • 2

    #1

    DCount syntax error when using WHERE...IN

    Access 2013

    I'm having trouble with my syntax. I'm getting a Run-time error 3075 missing operator

    This is the code that is causing the trouble:

    Code:
    vCount = DCount("[SalesID]", "[Additional Costs]", "Where [SalesID] IN (" & vSelected & ")")
    vSelected is a Variant and contains list of numbers for instance 62,63,64

    I want the DCount to count the records with the salesID 62,63,64 and return the number 3 (the number of records)

    I want to use vCount in a msgbox which says "you have selected " & vCount & " records."

    Thanks in advance!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You don't need the where when using dcount.

    Comment

    • muse79
      New Member
      • May 2015
      • 2

      #3
      What a silly mistake, thank you! Sometimes you can't see the wood for the trees!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        As Rabbit says - The Criteria parameter, of DCount() and other Domain Aggregate functions, is the in the same format as the WHERE clause in SQL, BUT doesn't include the text 'WHERE '.

        Comment

        Working...