Results 1 to 6 of 6

Thread: Running a total or balance in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    3

    Unhappy

    Probably not phrased correctly, but heres the prob...I've designed a vb form to use with a database (MSAccess). Using dataenvironment to connect the database. I need to allow the user to add (or subtract) money to their balance, then calculate a current balance based on the input. Any advise?
    indychyme

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    The question is are you planning on keeping all the various transactions or is the current balance all you ever need ?

    I'd design the database to have two tables, one that contains the Total amount and the other all the transactions to the account. After you write a record to the transaction table, you update the total table with the appropriate amount.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    3

    Unhappy same database issue...calculation

    Thanks for the response. The design is with two tables as suggested, but the problem is that it doesn't record the transactions when I test it. It will calculate based on whether I select credit or debit, but when I look over in the database nothing's there.
    indychyme

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Is the total being written or is _nothing_ being written?

    Can you post the code you're having problems with?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    3

    Unhappy

    Here's the code, I'm not sure if this is where my problem is though...

    Private Sub txtTransactAmt_Change()
    Dim Msg, Response
    Dim Recordset
    Dim I As Integer

    If optDebit.Value = True Then
    txtBalAfterTrans = CCur(CDbl(lblCurrentBalance) - CDbl(txtTransactAmt))
    Else
    If optCredit.Value = True Then
    txtBalAfterTrans = CCur(CDbl(lblCurrentBalance) + CDbl(txtTransactAmt))
    End If
    End If
    End Sub
    indychyme

  6. #6
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    What access method are you using, DAO or ADO? I'd expect to see a recordset update...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width