Results 1 to 5 of 5
  1. #1
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67

    Query Looking For Same Value In 3 Consecutive Days

    Hello,



    I have an Attendance table with the following fields:

    SSN
    Date
    Status (for ex, A = Absent, P = Present, E = Excused, etc)

    I want a query that will give me a student who has been Absent 3 (or more) consecutive days (Status "A" greater than 2 days in a row). Keep in mind that by days, I means days the class meets, so it could be that the student was absent 10/19/11, 10/21/11, and 10/24/11 if the class meets on Mons, Weds, and Fridays. It's also important to note that if the class is meeting 40 times in a semester over a 90 day period, only those 40 actual meeting dates are in the table, not all 90 days.

    Can anybody suggest an easy way to do this?

    Thanks,
    Al

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Probably not easy.
    Do you have a table that has all the dates classes will be held on?
    Sounds like will require VBA with recordsets.
    Last edited by June7; 10-18-2011 at 07:12 PM.
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    What are your table structures?
    What have you tried? What errors did you get?

  4. #4
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67

    Class Dates

    Yes, I append the 40 days (or whatever number) that the class meets to my student attendance table, along with class name, SSN, and attendance status.

    I haven't gotten any errors yet because I am not sure how to approach it. Looking for a game plan.

    How about if I add an autonumber field. Then in my query, I can add a criteria like:

    Status = "A" AND
    autonumber + 1 where status = "A" AND
    autonumber + 2 where status = "A"

    Does that seem like a logical direction to move in? Only problem I see is if the student was absent more than 3 times, I would get screwy results.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    If you have attendance status data for each student and each day, you might be able to use subqueries,

    You would need today, previous day and next day. You would be looking for "A" (absent) in those 3 positions.

    See allen Browne subquery for PriorValue at
    http://allenbrowne.com/subquery-01.html#AnotherRecord

    You will have to adjust the code to get the NextValue also.

    Good luck.

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

Similar Threads

  1. query with next hundred days
    By denny in forum Queries
    Replies: 2
    Last Post: 09-05-2011, 09:20 AM
  2. Comparing consecutive weeks data
    By foamcows in forum Queries
    Replies: 1
    Last Post: 08-16-2011, 08:20 PM
  3. multiple records with consecutive dates
    By sotssax in forum Forms
    Replies: 2
    Last Post: 07-26-2011, 04:23 AM
  4. number of days query
    By osuprog in forum Queries
    Replies: 15
    Last Post: 09-17-2010, 01:15 PM
  5. Select Dates between days and two days ago?
    By rstonehouse in forum Queries
    Replies: 4
    Last Post: 08-18-2010, 02:13 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