Results 1 to 10 of 10
  1. #1
    Divindunk is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2014
    Location
    Birmingham England
    Posts
    11

    How to sum a column in a query and restart when it hits a preset target and run a report from it

    Hi I am struggling with a problem for which I can see no solution but I am sure someone will have the answer! I have a query which has the following fields "Date", "ToolNo", "Description" and "Shots" the records are for mould tools and the volume of production logged by date. I need to be able to trigger maintenance levels on the tools by the number of cycles of each tool i.e number of "shots" made. There are 4 pre-set levels of maintenance for every 3000, 9000, 60000 and 150000 shots.



    So I need to be able to

    1. Restart counts for each of the four levels as they reach each threshold for each tool

    2. Produce a report which displays which tools have reached a particular maintenance level

    3. Be able to check mark and log a date, via a form, confirming when the maintenance has been carried out on the tool and thus removing them from the report until they reach the next threshold.

    I would say the I am an averagely skilled database builder with some knowledge of VBA but I have to confess I am all at sea with this! Any pointers or clues would be greatly appreciated. Thanks very much in anticipation.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    id imagine, youd continuously have the :
    tool, date, shots, inspectAt

    a tMaint table to show when work was performed on each tool.
    then set the next main inspection at [shot]=[shot]+3000, which sets it at: INSPECTat= 9594555.

    a query would compare the [InspectAt] to the [shot] count, if getting near, display this tool for inspection.
    no vba needed. But I dont see how the [shot] count is updated. (automatically via the tool??)

  3. #3
    Divindunk is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2014
    Location
    Birmingham England
    Posts
    11
    Hi thanks for the quick response not sure if I understand it yet but I'll take some time try! The shot data is entered at the end of each 8hr shift... no shop floor data collection yet :-( I think I get the drift of what you're saying, however the four different thresholds apply to all tools so the restart would only occur at 3000 for a basic clean down of the tool but at the other end of the scale 150000 is full tool room strip and refurbishment job and all the other intermediate maintenance levels occur during this 150000 shot period? So the count for maintenance would go 3000,3000,9000, 3000,3000,3000, ... 60000, 3000, 3000, 3000, ... 150000, so would I need four different counters for each tool? Thanks

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just an FYI....

    "Date", and "Description" are reserved words (as is "Desc") in Access and shouldn't be used for object names. "Date" is also a built in function.
    In addition, they are not very descriptive.
    "Date" of WHAT? Purchase date??? Install date?
    "Description" of WHAT?

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,426
    what happens if the number of shots for a machine at start of shift is 2999 and a shift does 800 shots - is it stopped after 1 shot, maintenance carried out then continues for the other 799? or does the shift continue for all 800 and is stopped at end of shift for maintenance so 3000 maintenance occurs at 3799 shots in which case does next maintenance count from 3000 or 3799? Or is the machine actually put to maintenance at 2200 before shift starts?

  6. #6
    Divindunk is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2014
    Location
    Birmingham England
    Posts
    11
    Thanks for the info regarding naming conventions, I will change them accordingly! Just for further info, does using reserved words cause any issues if they are used?

    Level 1 and 2 TPM are carried out while the tool is in the machine so yes it is stopped while these are carried out but for the more intensive levels 3 and 4 the tool must come out of the machine. The triggers are a guide so a couple of 100 shots either way is not an issue, (as with car servicing).

    As regards my problem I am beginning to think it might be easier to link it to excel and do the calculations there unless anyone has a solution? Thanks all

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,426
    does using reserved words cause any issues if they are used?
    yes - primarily generating errors with misleading descriptions making them difficult to track down.

    here is a list of reserved words
    https://support.office.com/en-us/art...7-da237c63eabe

  8. #8
    Divindunk is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2014
    Location
    Birmingham England
    Posts
    11
    Thanks for that.

  9. #9
    Join Date
    Apr 2017
    Posts
    1,679
    It is a rare case where storing a calculated value into table is best solution!

    Add into your log table a field named p.e ToolShotNo. Into BeforeUpdate event of form where the log is recorded, write a code to calculate current biggest ToolShotNo for tool, add 1, and write the result into text box on form linked to field ToolShotNo.

    In some table you must register your tool maintenance, p.e. ToolMaintenanceLog. There you register tool id, maintenance date, maintenance level - and ToolShotNo at which the maintenance was actually made (you calculate current MAX ToolShotNo for tool from log table, and save the result into ToolMaintenanceLog). From there to calculate next maintenance threshold is an easy task.

  10. #10
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044

    Example how you can do this

    Hi,

    in the attachment you'll find an example file how you can proceed. When using the example, there is some code using the Microsoft Active X Data Object library, so be sure to check in the reference window (VBA window -> Tools -> References)

    I added some tables (main table tools linked 1 to many on UsageTools, table levels with the 4 maintenance levels and a maintenance table) The main form is frmTools that has a subform that shows (not updatable, this is done automatically) the number of shots till the next maintenance/level and a subform that shows the number of shots/day.

    Success
    Noella
    Attached Files Attached Files

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

Similar Threads

  1. Update query to not include skus NOT in target
    By OldenMcdonald in forum Import/Export Data
    Replies: 6
    Last Post: 05-25-2017, 10:41 PM
  2. Replies: 27
    Last Post: 12-02-2015, 06:09 PM
  3. Replies: 3
    Last Post: 10-16-2015, 03:04 PM
  4. Restrict data entry to preset list
    By chrisfl in forum Forms
    Replies: 2
    Last Post: 06-28-2013, 01:16 PM
  5. Emailing a preset email draft from Access
    By jbickl in forum Access
    Replies: 2
    Last Post: 01-13-2012, 06:22 AM

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