Results 1 to 5 of 5
  1. #1
    MJCRN is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    4

    Question Autofill Table field with count of unique records

    Hello!
    I am very new to Access and am hoping this is a simple question. I have created a database that will compile information for our organization. I am trying to COUNT the number of visits each customer makes to the centre and have that number automatically updated in the Customer Information table.

    So I have Table 1: Customer Information, includes field for Number of Visits.
    I have another [Table 2] & Form that tracks Visit information.
    The Customer and Visits both have unique ID numbers.


    Can I write a query or something that will easily track this information?
    Please help!
    Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Normally you wouldn't store something that can be calculated from transactions, and I wouldn't store this. It can easily be calcuated with a totals query:

    SELECT Customer, Count(*) As HowManyVisits
    FROM Table2
    GROUP BY Customer

    With the appropriate table and field names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MJCRN is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    4
    Why wouldn't you store this information?

    I have now created a query that will list the number of visits each customer has made (which is great) but is there no way to put this information into the Customer table as a field that updates for each person as they continue to visit?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Allen has thoughts on why you shouldn't:

    http://allenbrowne.com/casu-14.html

    It can certainly be done, but you have to catch any time/method a record is added, modified or deleted in the transaction table. Or run an update query based on this query frequently. Why go through all that when the answer is so easily done with the query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    By the way, if your concern is wanting to query the customer table and get the count, in a new query you simply join the customer table with the query you just created and you're able to return customer info along with the current count. You could even put a criteria on the count query and get counts as of 12/31/15, or whenever. Much more flexible.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 22
    Last Post: 11-28-2015, 06:14 PM
  2. Create a Field to Calculate Unique/Distinct Count
    By MikeNewAccessUser in forum Queries
    Replies: 3
    Last Post: 03-06-2015, 08:39 AM
  3. Count Unique Records in a Report
    By Mohmand in forum Reports
    Replies: 2
    Last Post: 09-10-2014, 10:44 PM
  4. Count unique records - no duplicates
    By Kevo in forum Queries
    Replies: 4
    Last Post: 08-15-2011, 01:19 AM
  5. Count Unique Records
    By PonderingAccess in forum Queries
    Replies: 2
    Last Post: 08-19-2010, 06:54 AM

Tags for this Thread

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