How would you write the following in VBA?:
[frmPayment] has the following defaults: MemberID= [forms]![frmMember]![ID], PaymentDate= date() and the record source is [tblTransaction]
On opening [frmPayment],
run [qryBalanceReport] in background,
IF [qryBalanceReport].[SumOfDebt]= 0
THEN add (as a new record) the value of [tblMember].[totalDues] to [tblTransaction].[Debt],
AND set [frmPayment].[PaymentAmount] = [tblMember].[TotalDues].
ELSE [frmPayments].[PaymentAmount] = [qryBalanceReport].[Balance]
Note:
[qryBalanceReport] uses Totals to sum .[Credit] columns and .[Debt] columns respectively
and also returns .[Balance]: sum([Debt]-[Credit]).