Results 1 to 5 of 5
  1. #1
    Rzadziu is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    28

    Query for overdue maintenance

    Hi,



    I have a problem with building the query for overdue maintenance.

    Based on help from JoeM https://www.accessforums.net/queries...tml#post141350 i have built a query to get the last date of the maitenance (for each machine_id and Ctype)
    Now I would like to filter that to get those records for which DiffDate is larger than Ctype (for each machine_id and Ctype).

    At the end I would like to get the effect as in this picture where the window on the right saw all I will need to perform maitenance.


    Click image for larger version. 

Name:	M1.jpg 
Views:	7 
Size:	103.5 KB 
ID:	10651


    This is a query which i have create
    Code:
    SELECT Machinesmaintenance.MDate AS [Last Maitenance],  Maxofcontmachines.Machine_ID, Machinesmaintenance.Controler,  Machinesmaintenance.CType AS [Control type], Maxofcontmachines.DifDate,  Machines.Machine_name
    FROM Users INNER JOIN ((Machines INNER JOIN  Machinesmaintenance ON Machines.Machine_ID =  Machinesmaintenance.Machine_ID) INNER JOIN Maxofcontmachines ON  Machines.Machine_ID = Maxofcontmachines.Machine_ID) ON (Users.EmpID =  Machines.U1.Value) AND (Users.EmpID = Machinesmaintenance.Controler);
    But some records are shown several times.
    Click image for larger version. 

Name:	m2.jpg 
Views:	7 
Size:	88.4 KB 
ID:	10653

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Could you provide db for analysis? Follow instructions at bottom of my post.
    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
    Rzadziu is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    28
    Please have a look on attached file.

    Machines.zip

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You are using lookups in tables. I never do that. Review http://access.mvps.org/access/lookupfields.htm

    Consider:
    SELECT Maxofcontmachines.Machine_ID, Maxofcontmachines.MaxOfMDate, Maxofcontmachines.DifDate, Machines.Machine_name, Maxofcontmachines.CType
    FROM Machines INNER JOIN Maxofcontmachines ON Machines.Machine_ID = Maxofcontmachines.Machine_ID
    WHERE (((Maxofcontmachines.DifDate)>[CType]));
    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.

  5. #5
    Rzadziu is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    28
    That works perfectly for me thanks a lot.
    Last edited by Rzadziu; 01-14-2013 at 02:45 AM.

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

Similar Threads

  1. Counter Query for Maintenance
    By theperson in forum Queries
    Replies: 3
    Last Post: 10-23-2012, 05:17 PM
  2. Maintenance Database
    By shariq1989 in forum Database Design
    Replies: 1
    Last Post: 06-28-2012, 04:55 PM
  3. Setting an alert that a payment is overdue
    By bellevue in forum Database Design
    Replies: 6
    Last Post: 04-04-2012, 02:54 AM
  4. Replies: 5
    Last Post: 04-01-2012, 07:21 AM
  5. Creating a Maintenance Scheduler
    By squirrel in forum Forms
    Replies: 0
    Last Post: 02-15-2006, 03:45 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