Results 1 to 7 of 7
  1. #1
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376

    Calculation in a query?

    Hello all,

    I have a query built that is giving me exactly what I want. Now I want to take that query and expand on it, I want to be able to put in a PN and have the results output as they currently are but then add another field for "[Qty to Build]" and use the "Qty" and multiply that by the "[Qty to Build] which would be entered when the query is ran. I also want the query to create a new table. Is this something that can be done or is there another, better way to do it?

    The existing query consists of the following fields

    MfrPartNumber - this is the parent Assembly PN


    PartDescription - Description of the parent Assembly
    Child_Part_Number - PN of the child parts in the Assembly
    Qty - Qty of each child part
    Child_Part_Description - Description of the child Part

    I want the new table to have all of those fields plus another for Order Qty, so the new table would have the following fields.

    MfrPartNumber - this is the parent Assembly PN
    PartDescription - Description of the parent Assembly
    Child_Part_Number - PN of the child parts in the Assembly
    Qty - Qty of each child part
    Child_Part_Description - Description of the child Part
    Order_Qty - Calculated qty for each child part based on input qty for Order Qty when the query runs.

    Would it be better just to have the table predefined so the Order Qty field is already present and just recreate the table when the query runs?

    I was planning on have 2 input fields when the query runs, 1 for "Assembly Part Number" which I already have and is working great, and another for "Order Qty".

    Thanks

    Dave

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Why have code that creates table? A procedure that routinely creates tables indicates a non-normalized data structure. Why do you need data saved to a table as opposed to just using the query? If you need records saved, why not data entry through a form? Shouldn't [Qty to Build] be a field in the Orders table? Is [Qty to Build] synonymous with Order_Qty?
    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
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    June7,

    I thought it would be good to have the query create a table, then use the table to append another table for "Transactions" that will keep track of all transactions by part number. If I can do it with a form that would be great but I would have to use the query to pull all of the child part numbers together correct? Can I call a query from a form? I would also need to give the "Build" a lot number so I could capture the lot number to save that in the 'Transactions" too, I forgot about that in the initial post.

    Yes [Qty to Build] is synonymous with Order_Qty.

    Thanks
    Dave

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    I have processes where I use a 'temp' table to hold data then purge after. But the table is permanent, records are temporary. And database is split which means the 'temp' table is in the frontend.

    Code that routinely modifies db structure causes db bloat and increases chance of db corruption.

    Yes, query can be called by code behind form.

    I don't really understand what you are trying to accomplish.
    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
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    June7,

    I will try to put something together today at work and zip the file so you can actually see the data etc, and try to explain better what I am trying to accomplish.

    Thanks

    Dave

  6. #6
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    June7,
    What I want to do is take what ssanfu helped me with and expand on that. I want to create a work order based on that “frmPartMain” after the user has selected the Part Number they want, then I need a field to put in a “Lot Number” and a “Qty to Build” of that “Part Number” and have the info get written to the “Work Orders” table. I also have an extra Column in the “SubAssemblyInfo” subform for the “Build Qty” which will be the result of the “Qty” (in the subform)*”Qty to Build” (in the “frmPartMain”). I just can’t get this to work properly. I believe I have taken out my attempts that haven’t worked.

    Any Help is greatly appreciated.

    3-7-18 -In Process.zip

    Thanks
    Dave

  7. #7
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    I got this issue resolved, Thank You to those who replied and assisted.

    Dave

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

Similar Threads

  1. Calculation in query
    By youba14 in forum Access
    Replies: 4
    Last Post: 08-22-2016, 02:32 AM
  2. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  3. Query Calculation
    By Rhubie in forum Queries
    Replies: 4
    Last Post: 02-01-2013, 12:35 PM
  4. Query calculation
    By Charter in forum Queries
    Replies: 8
    Last Post: 12-30-2011, 11:50 AM
  5. Query Calculation
    By kellyd in forum Queries
    Replies: 5
    Last Post: 08-31-2009, 11:14 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