Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    How can pull this data?

    Hey there,

    I have the tables:

    TA1

    TrnNo PK-AutoNumber
    ProdnDate
    BodyNo
    Product
    Type

    TA2 Subtable of "TA1"
    BatchNo
    TrnNo
    abc
    dxy



    TB1
    RNo
    Rdate
    Product


    TechnID
    Reading
    ProdnDate


    I am preparing a query based on TB1 and i just need the following info from the above TA1.

    *How i can pull the right "BodyNo" based and comparing on "ProdnDate" and "Product" which is existing in both TA1 and TB1.

    please advise?

    thanks

    zee

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Suggest you post some sample data and expected results. Difficult to determine specifically what you are looking for. An example with data would be beneficial.

  3. #3
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    sir i think i must do that but so far it is just a concern to make a query combining all three tables where from TA1 just need "BodyNo" field and TB1 all fields in query.

    the linking key is the Prod'nDate and Product which is same in both TA1 and TB1.

    thanks

  4. #4
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Sir can u also look at my this post. i am sure u can solve as its a urgent enquiry.


    https://www.accessforums.net/reports...ort-21010.html

    thanks

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Have you tried to make the query? What does the SQL statement look like? What results do you get? Please work with us and supply information that we can use to help you.

    I could not open the file on the other thread. Please show some sample data and the expected results.

  6. #6
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hello Sir,

    i attached the sample database and having many questions related queries and reports but right now we will discuss about the few only and those are really urgent one and i need to solve tonight. i am sure you will help out as much as you can.

    Question-1.

    If you look at the tables "tblGlazing" and its sub-tables "tblGlazing1", "tblGlazing2" which are associated with One to Many relations.

    what kind of query will work to show the combine sum results of these three tables based on ProdDate field and Trndate is not important to be part of it.

    Question-2

    How we can retrieved some fields from "TblPress" to a query which is based on tblMT11 and sub-table "tblRT11" fields.

    - Required to pull "BodyNo" from "tblPress".

    - Common and linking data is "ProdnDate" and "Item" which is existing in both "tblPress" and tables "tbeMT11" and "tblRT11".


    Question-3

    How we can have combine query from the below given three sets of tables.

    Set1
    tblPress
    tblPress1
    tblPress2

    Set2
    tblGlazing
    tblGlazing1
    tblGlazing2

    Set3
    tblSorting
    tblSorting1
    tblSorting2

    Common and Process linking fields.

    Set1 to Set2 "DCarNo", "ProdnDate", "Product"
    Set2 to Set3 "KCarNo", "Product"


    Process:

    The "DCarNo" which is carrier to take "Product" through some process and reached at Set2 where those "DCarNo" unloaded and inspected then good one again passed ones glazed and loaded on "KCarNo" which is another carrier to take same product through some process and reached at set3 where again "KCarNo" is unloaded and inspected.

    I know this will be very helpful through some relational database structure but just help now in current scenario to generate the results.


    Please advise and very important to finished today.


    i will be grateful to you.

    thanks a lot.

    zee

  7. #7
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Sir waiting for u reply plz?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    Hard to understand what you are asking for. Maybe this will get you started.

    Question 1 - A Total (GROUP BY) query on the ProdnDate field.
    SELECT tblGlazing1.ProdnDate, Sum(tblGlazing1.GoodQty) AS SumOfGoodQty, Sum(tblGlazing1.RejectQty) AS SumOfRejectQty, Sum(tblGlazing2.ReasonQty) AS SumOfReasonQty
    FROM (tblGlazing LEFT JOIN tblGlazing1 ON tblGlazing.TrnNo = tblGlazing1.TrnNo) LEFT JOIN tblGlazing2 ON tblGlazing1.BatchNo = tblGlazing2.BatchNo
    GROUP BY tblGlazing1.ProdnDate;

    Question 2 - There is no TblPress but there is a tblPRS. Appears to be a simple SELECT with joins.
    SELECT tblMT11.*, tblRT11.*, tblPRS.BodyNo
    FROM tblPRS RIGHT JOIN (tblMT11 LEFT JOIN tblRT11 ON tblMT11.TestNo = tblRT11.TestNo) ON tblPRS.ProdnDate = tblRT11.ProdnDate;

    Question 3 - Doubt this can be accomplished in one query, if at all. Might even need report/subreport arrangement. Not going to tackle it.

    Often, getting the desired output is a matter of changing the JOIN TYPE of a query.
    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.

  9. #9
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hello Sir,

    thanks for ur time.

    Question1.

    It works in this way as you show the just sum of reasons qty but how we can show reject reasons in column heading against each record.?

    Question-2.

    Its working good. sorry for table mistake. its tblPRS.

    but there is two type of BodyNo running on same production for each kind of product. so is it will show up the correct data?

    as on same prodndate we have two products in tblPRS.

    Product BodyNo
    A 050
    B 060


    So is it not important when we retrieved data by linking tblPRS so 1st must match the product and then retrieved BodyNo?

    please advise?

  10. #10
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Quote Originally Posted by cap.zadi View Post
    Question1.
    It works in this way as you show the just sum of reasons qty but how we can show reject reasons in column heading against each record.?
    Is it that you want the results of the query in the below manner :

    Code:
    ProdnDate    Bend    Crack
    11
    /2/2011    1    2
    12
    /18/2011        22
    12
    /19/2011        12
    12
    /20/2011        14
    12
    /21/2011        29
    12
    /22/2011        22
    12
    /24/2011    1    5
    12
    /27/2011    1    9 
    Thanks

  11. #11
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Sir,

    yes i need the results like that but along with the goodqty and reject qty.

    ProdnDate GoodQty RejectQty Bend Crack

    i will appreciate your inputs.

    thanks

    zee

  12. #12
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Quote Originally Posted by cap.zadi View Post
    yes i need the results like that but along with the goodqty and reject qty.

    ProdnDate GoodQty RejectQty Bend Crack
    Just check out if below gives some guidelines :

    The sub-queries to be saved:
    qryGlazingsRejectionReasons
    Code:
    SELECT 
        tblGlazing2.BatchNo, 
        TblRReason.Reason, 
        Sum(tblGlazing2.ReasonQty) AS SumOfReasonQty
    FROM 
        tblGlazing2 
        INNER JOIN 
        TblRReason 
        ON 
        tblGlazing2.Reason = TblRReason.ReasonID
    GROUP BY 
        tblGlazing2.BatchNo, TblRReason.Reason;
    qryGlazingGoodRejection

    Code:
    SELECT 
        tblGlazing1.ProdnDate, 
        "GoodQuantity" AS GoodQuantity, 
        Sum(tblGlazing1.GoodQty) AS SumOfGoodQty
    FROM 
        tblGlazing1
    GROUP BY 
        tblGlazing1.ProdnDate
    ORDER BY 
        tblGlazing1.ProdnDate
    UNION ALL 
    SELECT 
        tblGlazing1.ProdnDate, 
        "RejectionQuantity" AS RejectionQuantity, 
        Sum(tblGlazing1.RejectQty) AS SumOfGoodQty
    FROM 
        tblGlazing1
    GROUP BY 
        tblGlazing1.ProdnDate
    ORDER BY 
        tblGlazing1.ProdnDate
    UNION ALL 
    SELECT 
        tblGlazing1.ProdnDate, 
        qryGlazingsRejectionReasons.Reason, 
        Sum(qryGlazingsRejectionReasons.SumOfReasonQty) AS SumOfSumOfReasonQty
    FROM 
        qryGlazingsRejectionReasons 
        INNER JOIN 
        tblGlazing1 
        ON 
        qryGlazingsRejectionReasons.BatchNo = tblGlazing1.BatchNo
    GROUP BY 
        tblGlazing1.ProdnDate, qryGlazingsRejectionReasons.Reason;
    Try to to run this final query after saving it :

    qryGlazingGoodRejection_Crosstab
    Code:
    TRANSFORM 
        Nz(Max(qryGlazingGoodRejection.[SumOfGoodQty]),0) AS MaxOfSumOfGoodQty
    SELECT 
        qryGlazingGoodRejection.ProdnDate
    FROM 
        qryGlazingGoodRejection
    GROUP BY 
        qryGlazingGoodRejection.ProdnDate
    PIVOT 
        qryGlazingGoodRejection.GoodQuantity;
    Thanks

  13. #13
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hey Sir,

    that's working good so far. can we add other fields along with Prodndate if will be required like Product?

    thanks for ur time and happy to see that.

    can you look at my other questions as well especially the 3rd one.

  14. #14
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    I just compare those results now and it seems to be the same with just direct Crosstab query.

    Code:
    TRANSFORM Sum(tblGlazing2.ReasonQty) AS SumOfReasonQty
    SELECT tblGlazing1.ProdnDate, Sum(tblGlazing1.GoodQty) AS SumOfGoodQty, Sum(tblGlazing1.RejectQty) AS SumOfRejectQty
    FROM tblGlazing INNER JOIN (tblGlazing1 INNER JOIN tblGlazing2 ON tblGlazing1.BatchNo = tblGlazing2.BatchNo) ON tblGlazing.TrnNo = tblGlazing1.TrnNo
    GROUP BY tblGlazing1.ProdnDate
    PIVOT tblGlazing2.Reason;
    the difference is the column heading is named with reasons ID (1 and 3) instead of Name like Crack and Bend.

    let me run the both in parallel for some time and see the data results.

    thanks

    zee

  15. #15
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Quote Originally Posted by cap.zadi View Post
    that's working good so far. can we add other fields along with Prodndate if will be required like Product?
    You will have to fiddle around. Please note : The queries I have given may not be good. If you have time, sit with them & see if you can improve on them. Also test them thoroughly.
    Quote Originally Posted by cap.zadi View Post
    can you look at my other questions as well especially the 3rd one.
    It's a bit difficult for me to understand what exactly you want from your questions. Will try whenever possible. Can you show us what the result of the queries for your 2nd & 3rd question should be? The way I showed you in my first reply. Perhaps it will be easier for others to help you. Thanks

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

Similar Threads

  1. Pull Data from another table
    By bbranco in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:15 AM
  2. pull up data from a table into a form
    By MattD00 in forum Forms
    Replies: 1
    Last Post: 03-30-2011, 08:15 AM
  3. Code to pull in data from a specific record
    By jdunn36 in forum Access
    Replies: 1
    Last Post: 09-20-2010, 11:54 AM
  4. Replies: 1
    Last Post: 03-23-2010, 09:18 AM
  5. Only pull out curtain data from a query
    By mela in forum Queries
    Replies: 0
    Last Post: 12-08-2009, 12: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