Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    TriFith is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37

    Quote Originally Posted by Dal Jeanis View Post
    I assumed it was dbo_components with an underscore. Is that a space between dbo and components? If not, I'll have to try downloading at home tomight.
    Of course, there is an underscore I am not using spaces too much...

  2. #17
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    k. I'll see if I can cut some time this weekend to review.

  3. #18
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    This gets a reasonable result.
    Code:
    SELECT 
      TC.ComponentName,
      TM.MachineName,
      T1.ProductionDate,
      First(T1.Picks) As Picks,
      First(T1.Placements) As Places,
      Sum(T2.Picks) AS CumPicks,
      Sum(T2.Placements) AS CumPlaces,
      Round((Sum(T2.Picks) -  Sum(T2.Placements))/Sum(T2.Picks),4) AS CumFail
    FROM
       ((dbo_PickPlaceEntries AS T1 
        INNER JOIN
        dbo_PickPlaceEntries AS T2
        ON T1.ComponentRID = T2.ComponentRID
        AND T1.MachineRID = T2.MachineRID)
          INNER JOIN dbo_Components AS TC
          ON TC.RID = T1.ComponentRID)
            INNER JOIN dbo_Machines AS TM
            ON TM.RID = T1.MachineRID
    WHERE T2.ProductionDate <= T1.ProductionDate
      AND T1.ProductionDate between #3/1/2013# AND #3/31/2013#
      AND T2.ProductionDate between #3/1/2013# AND #3/31/2013#
      AND T1.ComponentRID = 76
    GROUP BY 
      TC.ComponentName,
      TM.MachineName,
      T1.ProductionDate;

    You can replace the #3/1/2013#, #3/31/2013#, and 76 with the names of your form fields and execute the query from the form, and it should get you your desired results.

  4. #19
    TriFith is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37
    Hello again guys...
    I´ve just find out how to implement cumulative summary function in a querry...

    So:
    First step: In first querry I picked entries from-to date and for specific item and also I´ve sorted them by ProductionDate (format Date&Time)
    Code:
    SELECT dbo_PickPlaceEntries.ProductionDate, dbo_Components.ComponentName, dbo_Machines.MachineName, dbo_PickPlaceEntries.Picks, dbo_PickPlaceEntries.PlacementsFROM (dbo_PickPlaceEntries INNER JOIN dbo_Components ON dbo_PickPlaceEntries.ComponentRID = dbo_Components.RID) INNER JOIN dbo_Machines ON dbo_PickPlaceEntries.MachineRID = dbo_Machines.RID
    WHERE (((dbo_PickPlaceEntries.ProductionDate) Between [Forms]![frmStart]![Datum_od] And [Forms]![frmStart]![Datum_do]) AND ((dbo_Components.ComponentName)=[Forms]![frmStart]![Item]))
    ORDER BY dbo_PickPlaceEntries.ProductionDate;
    Second step: Next querry will calculate cumulative summary for data picked by previous querry.
    Code:
    SELECT *, (SELECT sum(Picks) FROM qryPickComponentData WHERE ProductionDate <= tmp.ProductionDate) AS CumulativeSumPicks, (SELECT sum(Placements) FROM qryPickComponentData Where ProductionDate <= tmp.ProductionDate) AS CumulativeSumPlacements
    FROM qryPickComponentData AS tmp;
    (as a third step I just calculated failrate like:
    Code:
    FailRate: (CumulativeSumPicks-CumulativeSumPlacements)/CumulativeSumPicks
    However...
    The key is to make sub-querry instead of DSum function in added fields...
    Unfortunatelly, this way is seriously time consuming! For every line, two more querries has to be done. For 40 entries it took me about 3 minutes to get a results and I need to perform this analysis for more than 1000 entries

    I am going to try a few more ways how to implement this function.

    At this time I would like to thank you all for help

    Cheers TriFith

  5. #20
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Okay, so here's your three queries all in one query.
    Code:
    SELECT 
      TC.ComponentName,
      TM.MachineName,
      T1.ProductionDate,
      First(T1.Picks) As Picks,
      First(T1.Placements) As Places,
      Sum(T2.Picks) AS CumPicks,
      Sum(T2.Placements) AS CumPlaces,
      Round((Sum(T2.Picks) -  Sum(T2.Placements))/Sum(T2.Picks),4) AS CumFail
    FROM
       ((dbo_PickPlaceEntries AS T1 
        INNER JOIN
        dbo_PickPlaceEntries AS T2
        ON T1.ComponentRID = T2.ComponentRID
        AND T1.MachineRID = T2.MachineRID)
          INNER JOIN dbo_Components AS TC
          ON TC.RID = T1.ComponentRID)
            INNER JOIN dbo_Machines AS TM
            ON TM.RID = T1.MachineRID
    WHERE (T2.ProductionDate <= T1.ProductionDate)
      AND (T1.ProductionDate between [Forms]![frmStart]![Datum_od]  AND [Forms]![frmStart]![Datum_do])
      AND (T2.ProductionDate between [Forms]![frmStart]![Datum_od]  AND [Forms]![frmStart]![Datum_do])
      AND (TC.ComponentName = [Forms]![frmStart]![Item])
    GROUP BY 
      TC.ComponentName,
      TM.MachineName,
      T1.ProductionDate;
    If you want to include cumulative fails from prior to the start of the period, then that requires a change to this line, for example by subtracting 30 days from the start date:
    Code:
      AND (T2.ProductionDate between [Forms]![frmStart]![Datum_od]  AND [Forms]![frmStart]![Datum_do])

  6. #21
    TriFith is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37

    Thumbs up

    Quote Originally Posted by Dal Jeanis View Post
    Okay, so here's your three queries all in one query.
    Code:
    SELECT 
      TC.ComponentName,
      TM.MachineName,
      T1.ProductionDate,
      First(T1.Picks) As Picks,
      First(T1.Placements) As Places,
      Sum(T2.Picks) AS CumPicks,
      Sum(T2.Placements) AS CumPlaces,
      Round((Sum(T2.Picks) -  Sum(T2.Placements))/Sum(T2.Picks),4) AS CumFail
    FROM
       ((dbo_PickPlaceEntries AS T1 
        INNER JOIN
        dbo_PickPlaceEntries AS T2
        ON T1.ComponentRID = T2.ComponentRID
        AND T1.MachineRID = T2.MachineRID)
          INNER JOIN dbo_Components AS TC
          ON TC.RID = T1.ComponentRID)
            INNER JOIN dbo_Machines AS TM
            ON TM.RID = T1.MachineRID
    WHERE (T2.ProductionDate <= T1.ProductionDate)
      AND (T1.ProductionDate between [Forms]![frmStart]![Datum_od]  AND [Forms]![frmStart]![Datum_do])
      AND (T2.ProductionDate between [Forms]![frmStart]![Datum_od]  AND [Forms]![frmStart]![Datum_do])
      AND (TC.ComponentName = [Forms]![frmStart]![Item])
    GROUP BY 
      TC.ComponentName,
      TM.MachineName,
      T1.ProductionDate;
    If you want to include cumulative fails from prior to the start of the period, then that requires a change to this line, for example by subtracting 30 days from the start date:
    Code:
      AND (T2.ProductionDate between [Forms]![frmStart]![Datum_od]  AND [Forms]![frmStart]![Datum_do])

    WOW!!!
    Gratulations :-D it´s working much more faster than my separated querries. Tried to run querry for 282 entries and I have a result after 5
    seconds. Great result!

    Thank you

  7. #22
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Happy to be of service. If it's working, please mark thread solved. top of page, under thread tools.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-06-2013, 02:32 PM
  2. Breaking out the time from date/time
    By detaylor1242 in forum Programming
    Replies: 1
    Last Post: 02-19-2013, 08:10 PM
  3. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 AM
  4. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  5. Replies: 6
    Last Post: 01-04-2011, 05:43 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