Results 1 to 6 of 6
  1. #1
    mdmcguire is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    2

    Newbie to Access. Help with a series of queries.

    Hello all.

    Essentially I have two tables that I need to set up queries from. The first table is called tblDB. It has two fields: name, and ID. This has the name of each person in my group and their ID number. The second table is called tblScanner. It also has two fields: ID and timestamp. This table is generated from a badge reader the reads in a persons ID number and time stamps it. I would like to set up queries that return each person in the groups name once (if they exist in tblScanner) and the number of times they have scanned their badge in the current month.

    I realize that this seems very basic. And it is. I am just very new to acces. I've been able to build these two tables and a form to read data from the badge scanner, but now I'm stuck on the queries because I know almost zero SQL. I've been looking at examples for almost a week now and am getting nowhere. If there is a better way to achieve this, let me know. Thanks in advance.

    Matt

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Should the count include this most recent scan? If so, that requires saving record to table first.

    One way to get the count is with a domain aggregate function by expression in a textbox ControlSource property:

    =DCount("ID","tblScanner","ID=" & Me.ID)

    Use as much criteria as needed to get the required count.

    = DCount("ID","tblScanner","ID=" & Me.ID & " AND Month([date fieldname])=" & Month(Date()))

    Save the current record and refresh the form and the count will calc.

    Record entry/edit is committed to table when form is closed, move to another record, or run code.
    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
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Code:
    SELECT TD.ID, First(TD.Name), Count(TS.TimeStamp)
    FROM tblScanner AS TS INNER JOIN tblDB AS TD ON TD.ID = TS.ID
    WHERE TS.TimeStamp >= #10/01/2013# AND TS.Timestamp < #11/01/2013#
    GROUP BY TD.ID;
    The hard-coded dates with the hash-tags # around them should be replaced with a function that determines the first day of the desired month and the first day of the next month, respectively.

    The reason you need "less than the first day of the next month" is that you're dealing with timestamps, and just after noon on #10/31/2013 12:20:00 PM# is mathematically greater than #10/31/2013#.

  4. #4
    mdmcguire is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    2
    Hi Dal Jeanis,

    Thank you very much for your help with this. The output is exactly what I wanted. Can you reccommend any reference to learn access/SQL from?

    Matt

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Start with post #5 in this thread https://www.accessforums.net/access/...ess-38592.html

  6. #6
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    ignore this post.

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

Similar Threads

  1. Multiple Series Charts
    By ejnitz in forum Queries
    Replies: 1
    Last Post: 02-13-2013, 10:26 AM
  2. Replies: 2
    Last Post: 06-20-2012, 03:56 PM
  3. Newbie getting stuck with summing queries
    By snorky in forum Access
    Replies: 2
    Last Post: 01-19-2012, 03:42 PM
  4. export a series of csvfiles
    By broecher in forum Programming
    Replies: 4
    Last Post: 09-23-2010, 09:10 AM
  5. Help Querying series
    By ktmchugh in forum Queries
    Replies: 20
    Last Post: 05-05-2009, 04:31 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