Results 1 to 7 of 7
  1. #1
    NigelW is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    4

    Question pulling data from a union query into a form or report, to calculate values

    Hi all,


    Sorry for this, however I seem to be chasing my own tail trying to solve my issue.
    I am creating a database system, which among other things will include a simple stock / inventory function.
    Among other tables I have 3 parts tables:

    Raw materials
    Fittings / assemblies
    Manufactured Items

    Each has different fields, but each has two particular fields in common
    PartNumber
    ItemValue

    I have a Union Query "AllPartsQuery", to pull all partNumber's and ItemValues into a single "List" (Query)
    This is used to generate the combo box used to select the PartNumber entry in the Stock Table PartNumber Field.
    Among other fields the Stock Table has the current STOCKQTY.

    At a future date, say stock taking, I will wish to run a report / query / form as appropriate to show the value of each line item, and of course a total stock value.

    I seem unable to get a method to make this work, I don't want (if avoidable, which is what I am trying to do) to put a Item value in the STOCK Table, I want to pull it from the appropriate Parts table or the "AllPartsQuery".

    I have tried making relationships, using a joining table, I have tried using the "AllPartsQuery" to utilise the ItemValue, but I seem to keep failing, one thing or another doesnt work.

    What should be the "normal / standard" way of doing this?
    I don't really want to have ALL product types (Raw materials / fittings / manufactured items) in the same table, as there is very little shared between these items,
    other than they all have a unique part number and each has a unit value.

    Hope this isn't too daft a requirement, but I am not getting anywhere.

    Many thanks in advance for any assistance, or pointing to an appropriate site / video.

    Regards
    Nigel

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,820
    Hi Nigel

    Can you upload a zipped copy of the database?

    If not then a screen shot of the Relationships window so we can see the table structures/

  3. #3
    NigelW is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    4
    Click image for larger version. 

Name:	relationships r1.jpg 
Views:	12 
Size:	177.8 KB 
ID:	39183

    screen shot, with some indications as to intent. I can zip and upload, but at this moment things are not entirely all there, as I have been mucking about.
    Attached Thumbnails Attached Thumbnails relationships r1.jpg  

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    So what happens if you use the union query and the stock table to get your query/report? Are the part numbers unique among the three tables?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    NigelW is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    4
    Hi,
    Yes the partnumbers are Unique in each and between all tables.
    Your answer triggered a thought, of using the union query as part of another query, to use in the form or report.
    I created a link, in the Query Design between the Stock and the AllPartsQuery, this then worked, and permitted me to then pull the data together, the unitvalues, and the stockqty.
    I then have entry to calculate the field "LineValue" in the new query. So far so good.
    I am now struggling to on the form, to provide a total stock value. The "LineValue" is on a subform, whilst the "TotalStock" is on the mainform.
    Click image for larger version. 

Name:	QueryStockWithValues1.jpg 
Views:	9 
Size:	95.8 KB 
ID:	39190
    Click image for larger version. 

Name:	TotalError.jpg 
Views:	9 
Size:	86.4 KB 
ID:	39191

    Click image for larger version. 

Name:	Sum Properties.jpg 
Views:	9 
Size:	74.5 KB 
ID:	39192
    Googling, this seems to be a not uncommon issue, however the answers seem variable, and to be honest half of them I didn't quite grasp.
    Is it possible to Sum the values generated as a calculated field in a Query, on a form or report?
    I.e. Query calculates
    LineValue: [STOCK QTY]*[UnitValue]
    This is then displayed on Form as "LineValue"
    Can I then sum the "LineValue"'s into a Total Value?

    Many thanks for the help and Patience.

    Regards
    Nigel

  6. #6
    NigelW is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    4
    Hi,
    Yes the partnumbers are Unique in each and between all tables.
    Your answer triggered a thought, of using the union query as part of another query, to use in the form or report.
    I created a link, in the Query Design between the Stock and the AllPartsQuery, this then worked, and permitted me to then pull the data together, the unitvalues, and the stockqty.
    I then have entry to calculate the field "LineValue" in the new query. So far so good.
    I am now struggling to on the form, to provide a total stock value. The "LineValue" is on a subform, whilst the "TotalStock" is on the mainform.
    Click image for larger version. 

Name:	QueryStockWithValues1.jpg 
Views:	9 
Size:	95.8 KB 
ID:	39190
    Click image for larger version. 

Name:	TotalError.jpg 
Views:	9 
Size:	86.4 KB 
ID:	39191

    Click image for larger version. 

Name:	Sum Properties.jpg 
Views:	9 
Size:	74.5 KB 
ID:	39192
    Googling, this seems to be a not uncommon issue, however the answers seem variable, and to be honest half of them I didn't quite grasp.
    Is it possible to Sum the values generated as a calculated field in a Query, on a form or report?
    I.e. Query calculates
    LineValue: [STOCK QTY]*[UnitValue]
    This is then displayed on Form as "LineValue"
    Can I then sum the "LineValue"'s into a Total Value?

    Further update I have managed to "Fix" it. I needed to create the sum functioned total ON the subform
    (not the main form) and then simply make the control source of the mainform box the subform calculated value box


    Many thanks for the help and Patience.


    Regards
    Nigel

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Glad to hear you solved it! Good luck with your projects!
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 4
    Last Post: 03-24-2018, 09:59 AM
  2. Replies: 2
    Last Post: 09-22-2016, 06:15 AM
  3. Pulling data into a form from query on a web app
    By DianeArthur in forum Access
    Replies: 0
    Last Post: 08-07-2016, 10:46 AM
  4. Replies: 5
    Last Post: 12-27-2012, 02:54 PM
  5. Replies: 0
    Last Post: 03-28-2011, 05:06 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