Expression to count number of times event occurrs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jesse Jones
    New Member
    • Jan 2011
    • 51

    Expression to count number of times event occurrs

    I am using the following expression in an access query. The goal is to count from tblAttedance how many times a particular employee (eid) is present (present = yes) for a particular type of event (SDY). Can someone please help? All I keep getting is #Error!!

    Code:
    DCount("tblAttendance_present","tblAttendance","tblAttendance_eID = " & [tblEmployees.tblEmployees_eID] & "AND tblAttendanceType = 'SDY' AND tblAttendance_present = 'Yes'")
    Thank you!!!!
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Looks to me that there are two problems in your WHERE clause: incorrect bracketing of the first field name (a dot in the middle of the bracketing), and a missing space before the first AND operator. Assuming that the field name in the first part is tblEMployees_eI D the syntax should be:

    Code:
    DCount("tblAttendance_present","tblAttendance","tblAttendance_eID = " & [tblEmployees].[tblEmployees_eID] & " AND tblAttendanceType = 'SDY' AND tblAttendance_present = 'Yes'")
    -Stewart

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      I confused as to why you're using a DCount rather than a join.

      Comment

      • Jesse Jones
        New Member
        • Jan 2011
        • 51

        #4
        Thank you! It is now working as
        Code:
        DCount("tblAttendance_present","tblAttendance","tblAttendance_eID = " & [tblEmployees.tblEmployees_eID] & "AND tblAttendance_Type = 'SDY' AND tblAttendance_present = Yes")
        This is working beautifully. I'm afraid I got a little too ahead of myself in asking this question before I was completely out of options. I'm sorry. Thank you for the help!

        Comment

        Working...