title: MS Access - Run a query displaying one result per user
body: <p>I've got a database that I'm tying into our access control system. I'm trying to create a report showing the user's first entry and last exit from the building. I've put a query together which hows me the right single result for one user, but I want to automate this to run through a list of users.</p>
  
  <p>The query for grabbing the first entry for one user (as it is currently) is as follows:</p>
  
  <pre><code>SELECT TOP 1 AccessLog.ID, AccessLog.Date, First(AccessLog.Time) AS FirstOfTime, AccessLog.User, AccessLog.Details, AccessLog.Event, AccessLog.Department, AccessLog.Where
  FROM AccessLog
  GROUP BY AccessLog.ID, AccessLog.Date, AccessLog.User, AccessLog.Details, AccessLog.Event, AccessLog.Department, AccessLog.Where
  HAVING (((AccessLog.Date)=#DATE#) AND ((AccessLog.User)="USERNAME") AND ((AccessLog.Where)="Front Door (In)"))
  ORDER BY First(AccessLog.Time);
  </code></pre>
  
  <p>I have a separate table of all the usernames, would it be possible to do a run-as for this?</p>
  
  <p>Basically I'm a complete Access n00b, in the past I'd have done this with PHP and a recurring function but this should be fairly easy to achieve within Access, shouldn't it? Any help much appreciated.</p>