Results 1 to 11 of 11
  1. #1
    b-ballstyle is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    9

    Copying value from previous record in a continuous form

    Alright, so I have a continous form on a form and i want to take a value in the previous record (BLUE), subtract one value in the current record (GREEN) and put that calculated value in the field (BLACK). All this by pressing the button on the current record (RED).. Is it possible? I can find any documentation on how to reference that previous record.. Please help
    Attached Thumbnails Attached Thumbnails untitled.PNG  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Are you saving Balance to table? Saving calculated data (data based on other data), especially aggregate data is usually a bad idea.

    This calc is easily accomplished on report. Textbox on report has a RunningSum property. To perform running subtraction, review http://stackoverflow.com/questions/5...ng-subtraction

    Doing this on form is more complicated because need to calculate running sum/subtraction of all previous records. This can be done with a subquery or DSum() function.

    Another possible approach is code to set the DefaultValue of a hidden textbox to the balance calculated in current record. Control Source of the visible Balance would be: HiddenBal - Used. Use the AfterUpdate event of Used textbox to set DefaultValue property of the hidden control.
    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
    b-ballstyle is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    9
    The balance is saved in my table.. I just want, on click of the button to take the last balance, sustract the USED value and set value to the balance.. I dont want that field to be "calculated", just a button that will set the value if you ask for it

  4. #4
    b-ballstyle is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    9
    Also this cant be a "calculated field" because the first value is entered manually

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Using code to set value of unbound textbox in a continuous/datasheet form will result in all instances of the textbox displaying same value. Therefore, my suggestion is the calculation be automatic or not at all. Doesn't matter if the Used value is entered or not, the Balance textbox will be Null until Used value is entered because calculations with Null result in Null.
    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.

  6. #6
    b-ballstyle is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    9
    Quote Originally Posted by June7 View Post
    Using code to set value of unbound textbox in a continuous/datasheet form will result in all instances of the textbox displaying same value. Therefore, my suggestion is the calculation be automatic or not at all. Doesn't matter if the Used value is entered or not, the Balance textbox will be Null until Used value is entered because calculations with Null result in Null.
    But I cant do it that way because for the first month of the list, I only have the balance (that I have to enter manually) and no used value..

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Like I said, not easy on forms. Forms are designed for data entry, reports are for data manipulation and output. That's the intent of Access designers and possibly of any relational database application.

    How much trouble do you want to go through to get this output on form?
    Google: access running balance on form
    Review http://social.msdn.microsoft.com/For...e-ea626e9de964

    I presume the monthly records are in a subform? The arrangement of fields under Ordered and Received indicates the database is not in normalized structure.
    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.

  8. #8
    b-ballstyle is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    9
    I know but I dont want a running sum. What I want to do, for example, is just take a value of a specific row and use it elsewhere.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    And that is what is hard. That is pulling a value from other record(s) in the dataset. Forms are not designed for that. 'Rows' in a form are not like 'rows' in a spreadsheet. Completely different concept. Each 'row' on form represents a record of data. These 'rows' are repetitions of the controls you see in Design view. So, they really aren't 'rows', not in the sense you see in a spreadsheet where specific value can be addressed in a calculation by cell coordinates. Cannot do that in relational database.
    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.

  10. #10
    b-ballstyle is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    9
    Yes but lets say you have a query you should be able to pull data from any record where certain information matches

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Yes, and that's what subqueries and domain aggregate functions are for.
    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. Moving to next/previous record in a form.
    By ser01 in forum Programming
    Replies: 3
    Last Post: 08-07-2012, 06:11 PM
  2. Replies: 3
    Last Post: 06-27-2012, 03:21 PM
  3. Delete continuous form record
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 03-09-2012, 03:00 PM
  4. Hiding a new record in a continuous form
    By system243trd in forum Forms
    Replies: 3
    Last Post: 12-03-2011, 01:04 AM
  5. Replies: 4
    Last Post: 09-09-2011, 10:00 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