DaniBoy
Registered User.
- Local time
- Today, 13:21
- Joined
- Nov 18, 2001
- Messages
- 174
Hello, I have a big problem!! I have a database that keeps track of invoices and payments recieved for the invoices.
"Invoice"
First of all I have a calculated field "Total" on my invoice form that is the sum of all items on the invoice detail subform. This field is an unbound and so the value is not saved anywhere. I also have an Amount Due field "I dont know if it should be bound or unvound?!, and I have a Paid checkbox field that is bound.
"Payment"
I have a form where I pick the ClientID from a dropdown and enter an amount of the payment recieved on a field. I also have a Applied checkbox field.
What I need!!
I need to run a code that will go and apply this payments. What I need it to do is the following:
1) I need it to find only does Invoices with the Paid Checkbox = false.
2)Find only the Payments with the Applied checkbox = false.
3)Find the all invoices with the same ClientID as the Payment ClientID.
4)Grab the "Amount due" amount and compare it to the "Payment" amount. If the amount of the "Payment" is greater than the amount of the "Amount due", subtract the "Amount Due" from the "Payment" amount, update the "Payment" amout to the difference and update the "Amount due" to "0", and update the Paid Checkbox to true, goto the next Invoice.
if the "Payment" amount is less then the "Amount due" subtract the "Payment" amount from the "Amount due" and update the Amount due to the difference and the payment to "0". Once the Payment has been applied update the Applied checkbox to True.
I just dont know how to do openrecordset and that VBA stuff yet
Thanks for helping me,
DaniBoy
"Invoice"
First of all I have a calculated field "Total" on my invoice form that is the sum of all items on the invoice detail subform. This field is an unbound and so the value is not saved anywhere. I also have an Amount Due field "I dont know if it should be bound or unvound?!, and I have a Paid checkbox field that is bound.
"Payment"
I have a form where I pick the ClientID from a dropdown and enter an amount of the payment recieved on a field. I also have a Applied checkbox field.
What I need!!
I need to run a code that will go and apply this payments. What I need it to do is the following:
1) I need it to find only does Invoices with the Paid Checkbox = false.
2)Find only the Payments with the Applied checkbox = false.
3)Find the all invoices with the same ClientID as the Payment ClientID.
4)Grab the "Amount due" amount and compare it to the "Payment" amount. If the amount of the "Payment" is greater than the amount of the "Amount due", subtract the "Amount Due" from the "Payment" amount, update the "Payment" amout to the difference and update the "Amount due" to "0", and update the Paid Checkbox to true, goto the next Invoice.
if the "Payment" amount is less then the "Amount due" subtract the "Payment" amount from the "Amount due" and update the Amount due to the difference and the payment to "0". Once the Payment has been applied update the Applied checkbox to True.
I just dont know how to do openrecordset and that VBA stuff yet
Thanks for helping me,
DaniBoy
Last edited: