Click to See Complete Forum and Search --> : Running a total or balance in VB
ChymeIndy
Jun 12th, 2000, 12:38 AM
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?
JHausmann
Jun 12th, 2000, 01:57 AM
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.
ChymeIndy
Jun 12th, 2000, 03:51 AM
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.
JHausmann
Jun 12th, 2000, 03:55 AM
Is the total being written or is _nothing_ being written?
Can you post the code you're having problems with?
ChymeIndy
Jun 12th, 2000, 06:39 PM
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
JHausmann
Jun 13th, 2000, 01:44 AM
What access method are you using, DAO or ADO? I'd expect to see a recordset update...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.