I’m trying to get an invoice/receipt payment allocation system built up in my Commercial Real Estate Database.
Because I need to bring together Invoice records and receipt records within the same recordset I’ve decided to go down the route of creating a temp table in VBA/SQL and populating the table with data from both Invoice and Receipts tables - as well as unbound columns, which will be filled with receipt data before writing pertinent data back to the underlying receipts table .
This temp table will be viewed in a subform, with common data (to all sub records) such as date of receipt etc being part of the Master form.
If my Invoice allocation system is to be anyway successful it needs to be able to:
• Receipt multiple amounts against a single (or multiple) invoices
• Be able to display an adjusted balance (in the sub form) for an outstanding invoice i.e. If a part payment is made prior to the current allocation event then this must be reflected.
I have been messing around with some test data and enclose a (stripped down) copy of my production DB.
• tblDRInvLineItem: contains the line items (or Invoice) number and the amount outstanding.
• tblDRRecM2M: Is a junction table for a many-to-many relationship between the Line item and Invoice Tables. This contains FK’s for the other two tables and effectively links receipts to invoice/line items
• tblDRRec: Contains the receipts information
The major issue that I have run into is when I try to display the adjusted outstanding balance. I originally thought that this would be quite simple; Create a query and then a simple expression to minus one from the other. Unfortunately, this doesn’t work when there is more than one receipt for a single invoice - I have receipted two $50 payments against one $100 invoice.
You can see this demonstrated in ‘qryInvoice_Receipts’ (Look at the line item ID and then the 2nd record total).
I then decided to sum the Receipts column (qryInvoice_Receipts2), expecting the result $100 - $100 = 0, but I get $50 as an answer. I understand why this is happening so I have decided to try my hand at (my first) sub query. The idea is to calculate the sum of receipts in the inner query and then use that result in the outer query to calculate the adjusted balance.
This is where things start to get tricky for me as I have been relying on access to create the syntax SQL for me, but now I have to do this myself.
Can anyone offer any advice or -hopefully – a solution to my frustrating problem?
Because I need to bring together Invoice records and receipt records within the same recordset I’ve decided to go down the route of creating a temp table in VBA/SQL and populating the table with data from both Invoice and Receipts tables - as well as unbound columns, which will be filled with receipt data before writing pertinent data back to the underlying receipts table .
This temp table will be viewed in a subform, with common data (to all sub records) such as date of receipt etc being part of the Master form.
If my Invoice allocation system is to be anyway successful it needs to be able to:
• Receipt multiple amounts against a single (or multiple) invoices
• Be able to display an adjusted balance (in the sub form) for an outstanding invoice i.e. If a part payment is made prior to the current allocation event then this must be reflected.
I have been messing around with some test data and enclose a (stripped down) copy of my production DB.
• tblDRInvLineItem: contains the line items (or Invoice) number and the amount outstanding.
• tblDRRecM2M: Is a junction table for a many-to-many relationship between the Line item and Invoice Tables. This contains FK’s for the other two tables and effectively links receipts to invoice/line items
• tblDRRec: Contains the receipts information
The major issue that I have run into is when I try to display the adjusted outstanding balance. I originally thought that this would be quite simple; Create a query and then a simple expression to minus one from the other. Unfortunately, this doesn’t work when there is more than one receipt for a single invoice - I have receipted two $50 payments against one $100 invoice.
You can see this demonstrated in ‘qryInvoice_Receipts’ (Look at the line item ID and then the 2nd record total).
I then decided to sum the Receipts column (qryInvoice_Receipts2), expecting the result $100 - $100 = 0, but I get $50 as an answer. I understand why this is happening so I have decided to try my hand at (my first) sub query. The idea is to calculate the sum of receipts in the inner query and then use that result in the outer query to calculate the adjusted balance.
This is where things start to get tricky for me as I have been relying on access to create the syntax SQL for me, but now I have to do this myself.
Can anyone offer any advice or -hopefully – a solution to my frustrating problem?