ryancgarrett
Board Regular
- Joined
- Jun 18, 2011
- Messages
- 122
I have a form in an accounting program I'm working on where a user can input a transaction. The form allows the user to select an account from a combo box, input an amount, and using an option button select whether it is a debit or a credit. In accounting debits must equal credits before you may go on, so I am trying to make it so the "Submit" button is disabled until the debits and the credits are the same. (I wish I knew of a way to put my form up here; if anyone knows how please tell)
At the bottom of the form I want the total debits and the total credits, each textbox updating when an option button is clicked. Here is my code which doesn't seem to work at all...
Note: If the debits or credits are equal to zero the textboxes showing the sum should be blank.
At the bottom of the form I want the total debits and the total credits, each textbox updating when an option button is clicked. Here is my code which doesn't seem to work at all...
Code:
Sub formBalance()
Dim SumofDebits As Long
Dim SumofCredits As Long
SumofDebits = frmTransactionEntry.optDebit1.Value + frmTransactionEntry.optDebit2.Value + frmTransactionEntry.optDebit3.Value + frmTransactionEntry.optDebit4.Value + frmTransactionEntry.optDebit5.Value + frmTransactionEntry.optDebit6.Value
SumofCredits = frmTransactionEntry.optCredit1.Value + frmTransactionEntry.optCredit2.Value + frmTransactionEntry.optCredit3.Value + frmTransactionEntry.optCredit4.Value + frmTransactionEntry.optCredit5.Value + frmTransactionEntry.optCredit6.Value
FormatCurrency (frmTransactionEntry.tbxAmount1.Value)
FormatCurrency (frmTransactionEntry.tbxAmount2.Value)
FormatCurrency (frmTransactionEntry.tbxAmount3.Value)
FormatCurrency (frmTransactionEntry.tbxAmount4.Value)
FormatCurrency (frmTransactionEntry.tbxAmount5.Value)
FormatCurrency (frmTransactionEntry.tbxAmount6.Value)
If SumofDebits <> 0 And SumofDebits = SumofCredits Then
frmTransactionEntry.cbtnSubmit.Enabled = True
frmTransactionEntry.tbxSumOfDebits.Visible = True
frmTransactionEntry.tbxSumOfCredits.Visible = True
ElseIf SumofCredits <> 0 And SumofDebits = SumofCredits Then
frmTransactionEntry.cbtnSubmit.Enabled = True
frmTransactionEntry.tbxSumOfDebits.Visible = True
frmTransactionEntry.tbxSumOfCredits.Visible = True
End If
End Sub