Results 1 to 3 of 3
  1. #1
    EileenAchil is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2016
    Posts
    3

    Wink Newbie Here! Please help me to solve this query..

    Hi, I'm new to access. I'm trying to make a attendance report (Who's Still In) based on this data.



    Table

    Click image for larger version. 

Name:	table.png 
Views:	13 
Size:	16.1 KB 
ID:	26542 My Query
    SELECT Attendance.[Staff ID], Attendance.StaffName, Attendance.Process, Attendance.Shiff, Attendance.Date, Attendance.Time, Attendance.Code
    FROM Attendance INNER JOIN Query1 ON (Attendance.Date = Query1.MaxOfDate) AND (Attendance.Time = Query1.MaxOfTime) AND (Attendance.[Staff ID] = Query1.[Staff ID])
    GROUP BY Attendance.[Staff ID], Attendance.StaffName, Attendance.Process, Attendance.Shiff, Attendance.Date, Attendance.Time, Attendance.Code
    HAVING (((Attendance.Code)="IN"));

    Result:
    Click image for larger version. 

Name:	result.png 
Views:	13 
Size:	10.8 KB 
ID:	26543

    What i actually want is to calculate (total staff)& who's still in the building.
    http://www.access-programmers.co.uk/...=1#post1512343

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I realize this is your first post here. It is helpful to readers if you describe your "business" in simple terms. Give an example with sample data showing input and desired output.


    Seems to be cross posted. http://www.access-programmers.co.uk/...d.php?t=290664

    When you cross post, tell readers you have done so. Here's why.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,424
    The answer was provided there, but the OP doesn't seem to have followed it. I can see there is one variation - from the original data provided it looked like date and time was one field, but from this thread they are separate - which is fine for a singles days worth of data, but if the table contains multiple days, it won't work. Also Date and Time are reserved words which will cause issues

    e.g.

    staffID...Date.............Time
    1..........11/16/2016...17:30
    1..........11/17/2016...17:29


    max of date= 11/17/2016

    max of time=17:30

    result - no records returned.

    change your query from

    max(date) as maxofdate, max(time) as maxoftime

    to max(date+time) as maxofdatetime



    and your posted query to

    ....ON (Attendance.Date+Attendance.Time = Query1.MaxOfDateTime) AND (Attendance.[Staff ID] = Query1.[Staff ID])

    and change the field names to avoid conflicts: Date means today, and Time mean now

    here is a link to reserved words

    https://support.office.com/en-us/art...ad=US&fromAR=1

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

Similar Threads

  1. how to solve this error?
    By ariansman in forum Forms
    Replies: 2
    Last Post: 04-30-2013, 06:16 AM
  2. Replies: 3
    Last Post: 03-13-2013, 04:00 PM
  3. how to solve this double query
    By gunterhoflack in forum Access
    Replies: 11
    Last Post: 01-28-2013, 07:58 AM
  4. Replies: 3
    Last Post: 12-18-2011, 04:17 AM
  5. can you solve my problem please?
    By grad2009 in forum Access
    Replies: 2
    Last Post: 02-16-2010, 05:02 PM

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