Results 1 to 5 of 5
  1. #1
    Persist is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2010
    Location
    Melbourne Australia
    Posts
    32

    Cumulative totals: Cannot edit a field in recordset

    I want to calculate the cumulative totals for each account in my database

    I created a query qCumTot with four fields
    Account: text field sort ascending from another table
    Date:
    Income: Currency from another table
    CumTot: Created in this query and set to set = 0

    I intended to overwrite CumTot using visual basic
    so I could see the results in the output of the query

    Dim db As Database
    Dim rs As Recordset
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("qCumTot")



    Looping thorough record set I can calculate CumTotal
    But I cannot overwrite rs![CumTot}

    rs.Edit
    rs![CumTot] = CumTotal
    ‘ Gives Error 3164:
    ‘ Field cannot be updated, another process has locked record or table
    rs.Update

    Any suggestions

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Saving calculated aggregate data to table is usually poor design and problemmatic as you found out. The aggregate total should be calculated when needed. This would be a Totals (GROUP BY) query.

    Can build a report with grouping on account and textboxes with Sum function. This will allow aggregate calcs and display of detail records.
    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
    Persist is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2010
    Location
    Melbourne Australia
    Posts
    32
    [Saving calculated aggregate data to table is usually poor design
    *** Yes I tried to avod this by saving to a query. Is that poor design?

    and problemmatic as you found out.
    ***** Yes. It did not work. Can I get it to work.
    I would like to calculate running totals so I can more easily check against my bank statements

    The aggregate total should be calculated when needed. This would be a Totals (GROUP BY) query.
    *** I have done GROUP BY overall totals for each account. This gives me the current balance for each account but not how the balance has moved with each transaction

    Can build a report with grouping on account and textboxes with Sum function. This will allow aggregate calcs and display of detail records.
    ** Could you say more about this

    Thanks

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Review Access Help on building reports that use grouping & sorting and aggregate calcs. No sense in me trying to repeat the help manual.

    Here is a web tutorial: http://office.microsoft.com/en-us/ac...aspx?section=5

    Textboxes in report offer a RunningSum property.

    You don't 'save' to a query. Queries manipulate data, an UPDATE query can even modify values in table. Data can even be entered into an editable SELECT query and the values will pass through to the source tables.
    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
    Persist is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2010
    Location
    Melbourne Australia
    Posts
    32
    You wrote "Textboxes in report offer a RunningSum property."
    ***** This was GOLD
    I googled “access report runningsum property”
    I found detailed instruction
    This worked – an easy way to get cumulative totals

    You wrote
    You don't 'save' to a query. Queries manipulate data, an UPDATE query can even modify values in table. Data can even be entered into an editable SELECT query and the values will pass through to the source tables.
    *** I meant that I defined a new field in my query and set it to zero in this query so access would know it was a numeric field. Then I attempted to overwrite this field with my VBA calculated cumulative total. This overwriting was not allowed.
    It does not matter now. The report running sum does the trick.

    Thanks

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

Similar Threads

  1. bind field to adodb.recordset field
    By gem1204 in forum Access
    Replies: 7
    Last Post: 04-26-2012, 01:07 PM
  2. Edit Data in Recordset
    By Bwilliamson in forum Programming
    Replies: 3
    Last Post: 05-12-2011, 08:29 AM
  3. Totals, Cumulative, and Break-Even Help
    By oregoncrete in forum Programming
    Replies: 3
    Last Post: 03-23-2011, 10:09 AM
  4. Replies: 1
    Last Post: 11-13-2009, 03:03 AM
  5. Can't Edit Date Field
    By MOtis in forum Forms
    Replies: 1
    Last Post: 09-10-2009, 03:57 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