Results 1 to 7 of 7
  1. #1
    chr1stoper1 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    57

    reset counter to zero

    Hi Guys

    Im try to make a database help me out servicing machine tools .
    I can pull the quantity of products produced from a sql server and have made a report which has conditional formatting to warn when a service is coming up or has past the qty set for a required service .
    My problem is how to tackle the resetting of the count as the sql will continuously count and id like to use access to rest to zero and start the count again . Any help with this is much appreciated

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    What's the query for your count?
    Are there any date fields available in the source data that you could use/store to only count from that date?

    Without a bit more detail it's hard to offer a more sensible answer or approach.

    Perhaps a look at the source tables structure might help?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    chr1stoper1 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    57
    Hi Minty

    Thanks for the reply. The information gathered from the sql is basically (part name) (Part number) (date production started ) (Date production finished ) and (qty made) these are molded parts from mold tools . The mold tools have different amounts of cavities so to find out the number of time s the tool has cycled the query runs a simple qty/cavities .This information is summed up so there is a running total in access and the report flags up when its close to service time . Once serviced how can i reset to start counting afresh ? The sql will continue to count total ammounts . I hope thats a little clearer

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Add a date field to your table for when the service is completed. Count/calculate parts made from the Max of that date field to today and grouped by each serviceable thing. This would probably end up being a Totals query.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You would reset the counter when the service has been completed.

    How would you do it manually/on paper ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,180
    How do you pull the data from SQL server? Is it a linked table or do you import and refresh the data on regular times? In the first case, you can't add an Access column's to the table. In any case I would create a Maintenance table in Access and link it to the SQL or import table. I would add fields partNumber, maintenanceDate and ProducedQtyOnMaintenance. All you have to do is write a query where you calculate the naw quantity as SQL_Quantity - ProducedQtyOnMaintenance, no need to reset qty to 0.

  7. #7
    madpiet is online now Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    Quote Originally Posted by chr1stoper1 View Post
    Hi Minty

    Thanks for the reply. The information gathered from the sql is basically (part name) (Part number) (date production started ) (Date production finished ) and (qty made) these are molded parts from mold tools . The mold tools have different amounts of cavities so to find out the number of time s the tool has cycled the query runs a simple qty/cavities .This information is summed up so there is a running total in access and the report flags up when its close to service time . Once serviced how can i reset to start counting afresh ? The sql will continue to count total ammounts . I hope thats a little clearer
    I'd use a windowing function in SQL Server. Much easier that way.

    Say I have a table of (Product, ProductionDate, Qty)

    the query would be

    SELECT Product,
    ProductionDate,
    Qty,
    RunningTotal = SUM(Qty) OVER (PARTITION BY Product ORDER BY ProductionDate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
    FROM MyTable;

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

Similar Threads

  1. Replies: 27
    Last Post: 12-02-2015, 06:09 PM
  2. How to add counter to StrSQL vba?
    By Jo.. in forum Queries
    Replies: 2
    Last Post: 09-09-2015, 08:09 AM
  3. Loop Counter
    By elementalnature in forum Programming
    Replies: 3
    Last Post: 09-17-2012, 10:00 PM
  4. Counter
    By Skroof in forum Access
    Replies: 3
    Last Post: 05-14-2012, 08:25 AM
  5. lap Counter
    By challenger in forum Access
    Replies: 4
    Last Post: 07-06-2010, 02:20 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