help with "BalanceDue" on Invoicepayment form?

B

Brook

Good Day all,

I have frminvoices that I use to create invoices and apply payments. The
frminvoicepaymentssubform pulls the invoicenumber, invoicetotal from the
frminvoices, and as payments are applied, they are deducted from the
invoicetotal.

The problem that I am having is that my code is applying payments as a
running sum instead of for each invoicenumber.

Below is my code, if anyone can help me set this up so that the
"BalanceDue" is calculated for each invoicenumber and invoicepayment subform?

I have a field on my form labeled: BalanceDue with a control source
"=MyNewBalance()"

The reason that I am trying to set this up is so that once the balance due
is "0" then a checkbox is updated to Paid in Full and taken off my open
invoice report.

Thanks in advance..

Brook

begin Code:
Private Function MyNewBalance() As Currency
Dim curInvoiceTotal As Currency
curInvoiceTotal = Me.Parent.Form![invoicetotal]

If Nz([paymentdate], 0) = 0 Then
'Set to zero to avoid triggering an error in the Dsum call

MyNewBalance = 0
Else

MyNewBalance = curInvoiceTotal - DSum("[PaymentAmount]",
"tblinvoicePayments", _
"[PaymentDate] <= #" & [paymentdate] & "#")
End If
End Function


End Code:
 
U

UpRider

For your Dsum, your criteria is for a specific payment date. It should be
for a specific invoice number. Using the date will just sum up all the
payments made on that date, regardless of the invoice number or even the
customer!

MyNewBalance = curInvoiceTotal - DSum("[PaymentAmount]",
"tblinvoicePayments", _
"[InvoiceNO] = " & me.[txtInvoiceNO)


HTH, UpRider
 
B

Brook

Thank you...

That worked perfectly!

Brook


UpRider said:
For your Dsum, your criteria is for a specific payment date. It should be
for a specific invoice number. Using the date will just sum up all the
payments made on that date, regardless of the invoice number or even the
customer!

MyNewBalance = curInvoiceTotal - DSum("[PaymentAmount]",
"tblinvoicePayments", _
"[InvoiceNO] = " & me.[txtInvoiceNO)


HTH, UpRider

Brook said:
Good Day all,

I have frminvoices that I use to create invoices and apply payments. The
frminvoicepaymentssubform pulls the invoicenumber, invoicetotal from the
frminvoices, and as payments are applied, they are deducted from the
invoicetotal.

The problem that I am having is that my code is applying payments as a
running sum instead of for each invoicenumber.

Below is my code, if anyone can help me set this up so that the
"BalanceDue" is calculated for each invoicenumber and invoicepayment
subform?

I have a field on my form labeled: BalanceDue with a control source
"=MyNewBalance()"

The reason that I am trying to set this up is so that once the balance
due
is "0" then a checkbox is updated to Paid in Full and taken off my open
invoice report.

Thanks in advance..

Brook

begin Code:
Private Function MyNewBalance() As Currency
Dim curInvoiceTotal As Currency
curInvoiceTotal = Me.Parent.Form![invoicetotal]

If Nz([paymentdate], 0) = 0 Then
'Set to zero to avoid triggering an error in the Dsum call

MyNewBalance = 0
Else

MyNewBalance = curInvoiceTotal - DSum("[PaymentAmount]",
"tblinvoicePayments", _
"[PaymentDate] <= #" & [paymentdate] & "#")
End If
End Function


End Code:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top