Results 1 to 7 of 7
  1. #1
    hjnash is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2013
    Posts
    34

    I need my form to get the value of Balance field when I start a new record entry

    I finally got the database started and in part date entry is working. I am stuck however with a simple
    aspect of the money management process. The database has 4 currency fields; they are,
    Opening_Deposit, Deposit, Spending, and balance. When I enter a record say Opening_Balance 300.00 the
    code will add balance to Opening_Deposit and enter the total in Balance, this works. Now I hit page down
    in the form to get a new record. This must show the balance from the last record. I can not figure the logic
    to get started. Even if I figure that out I may not figure out the code structure. SO anyone what to point me


    in the direction I need to go?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    There are a couple of ways to do this, but you can use the AfterUpdate event of the Control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record.

    To be honest, I'm a little confused as to what you're trying to do with what, here, but in the code below, you need to replace

    Opening_Balance

    with the actual name of the Control that you want to be automatically populated, when you create a New Record.

    You then need to replace

    Balance

    with the actual name of your Control that holds the data that you want to carry forward to the New Record
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
       Me.Opening_Balance.DefaultValue = """" & Me.Balance.Value & """"
    End Sub


    Linq ;0)>

  3. #3
    hjnash is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2013
    Posts
    34
    Thank you I will see If I can make this work, Still looking this stuff up on the internet.

  4. #4
    hjnash is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2013
    Posts
    34
    I was not able to get this to work, in my form how do I add a new control? Do I need to have a matching field in the table for the control?
    I spent the last week reading my new book but it does not cover this topic, so I have been reading posts in this forum but do not see what
    I am looking for can you provide a little more info please.

    Thanks Harry Nash!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    It would be a big violation of normalization rules to store the balances. Just store the transactions and calculate balances on form/reports. What happens when you edit a transaction? All later records are then wrong. You should also have a date/time field so you can order the records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    hjnash is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2013
    Posts
    34
    I have removed fields in the table for now to make the money balance Challenge uncluttered in the reports, I will
    add date and other fields back in once I get the balance working. I just am not able to figure out how to get the
    balance and even if I figure that out, how then do I display this balance. I am sure I need to have an event that
    will fire off when I open the data entry form, perhaps even the query should have the total. So I need help with!
    what is the best event trigger to use.
    what code do I write to get the balance.
    how do I display the balance.

    Thanks Harry Nash!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I think you need the date field now, or some field that enables you to sort the records. If you search on running sum or balance you should get several methods. You can do it in a query with DSum() or a subquery, in a report with the running sum property of a textbox, etc. It can be done with code, but it's probably not necessary.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Show Running Balance on Data Entry Form
    By hawzmolly in forum Forms
    Replies: 5
    Last Post: 06-30-2019, 03:27 AM
  2. Replies: 3
    Last Post: 03-09-2013, 10:39 AM
  3. Replies: 4
    Last Post: 08-14-2012, 07:14 AM
  4. Replies: 6
    Last Post: 04-17-2012, 10:32 AM
  5. Replies: 12
    Last Post: 06-10-2011, 10:19 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