Results 1 to 5 of 5
  1. #1
    JakeMann41 is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    14

    Calculating 2 fields in a Query

    Hi All

    I have a query that looks at 2 tables

    OpeningStockTable and MovementsTable

    I have an Expression that calculates fields within those tables - [OpeningStock]+[QtyMovement]



    When I run the query I get the result I want.

    However, is it possible to then change that opening qty to a new qty based on the result of the query?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    I would say no?
    How can you expect to change the source of something where whether you do or not relies on the result of that source?

    You might be able to use a tempvar set to that result and then amend the qdf.sql to suit, but you have to determine whatever first and not from what you wish to amend.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    u can change the output into select "update ..." with text strings for the update sql so u can run the update later

  4. #4
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,180
    When a movement is validated, you can run an update query where you set StockQty= StockQty + MoveQty without first running a select query. That's how it's done in most of the warehouse applications. This way you always have the correct current stock qty. Or you can do it with a SQL statement in VBA.

  5. #5
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    nice to confirm but sql not need in vba , but vba is the place to do all

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

Similar Threads

  1. Replies: 3
    Last Post: 03-29-2022, 09:53 AM
  2. Query not calculating all fields
    By koncreat in forum Queries
    Replies: 2
    Last Post: 09-27-2018, 02:50 PM
  3. Calculating a two date fields! Help please
    By Enigma in forum Access
    Replies: 3
    Last Post: 01-29-2017, 11:32 AM
  4. Replies: 0
    Last Post: 03-09-2012, 07:04 AM
  5. calculating time fields
    By donnan33 in forum Programming
    Replies: 5
    Last Post: 01-19-2012, 12:15 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