Results 1 to 5 of 5
  1. #1
    KpAtch3s is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    6

    Update query pulls over only first field in column

    I have two tables InventoryT and NewInventoryT plus a query NewInventoryQ. Last column in the query totals current inventory on hand and new inventory that is entered into a column through a form (NewInventoryF). I have put a button on this form that uses an update query that takes these new totals from the totals column and updates the [Quantity] column on InventoryT.

    This works to a point. My update query only takes the value in the first field in the [Total] column of NewInventoryQ and enters the same value into the entire column of the [Quantity] column of InvetoryT.

    I'll be adding more functions to this, but below is the code in my button as of now.

    Dim cpyString As String


    Private Sub UpdateInventoryT_Click()


    cpyString = "UPDATE InventoryT SET Quantity = Total"
    DoCmd.RunSQL cpyString
    End Sub

  2. #2
    DrGUI is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Parts Unknown
    Posts
    23
    I follow the philosophy that you never store a calculated value in a table. Just calculate it when you need to use it (i.e. in a form, a query, or report).

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Especially aggregate data. It should be calculated when needed. Review http://allenbrowne.com/AppInventory.html
    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.

  4. #4
    KpAtch3s is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    6
    I guess I thought I would be avoid any potential problems by using an update query as above instead of having the totals column directly updating the InventoryT. I'll check out the link. Thanks.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is the difference - either way calc is saved? The point we are trying to make is that calculated data, especially aggregate calcs, should not be saved to table (not without strong justification). The risk is that raw data and calc data can get 'out of sync'.

    Having said that, I do have a db where I save calculated data - however, none are aggregate calcs.
    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.

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

Similar Threads

  1. Query pulls duplicates
    By TazoTazmaniac in forum Queries
    Replies: 7
    Last Post: 02-19-2015, 03:56 AM
  2. Replies: 2
    Last Post: 12-04-2013, 03:58 PM
  3. Creating a search Field that pulls up a record
    By RapidRepairArnold in forum Access
    Replies: 3
    Last Post: 10-17-2012, 04:33 PM
  4. Replies: 6
    Last Post: 07-25-2012, 06:42 AM
  5. Form pulls totals from query
    By seth.murphine in forum Forms
    Replies: 3
    Last Post: 04-17-2012, 08:23 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