473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sum of balances for a repeating Invoice Number

77 64KB
Referencing post: -http://bytes.com/topic/access/answer...eating-invoice
I need some help with the calculation of invoice amounts on a Microsoft Access 2010 report. My report shows the following fields; -invoice#, invoice amount, payment amount, and payment due (i.e. payment due = payment amount - invoice amount). There are some invoice numbers have balances for their different regional offices:
for example:
Expand|Select|Wrap|Line Numbers
  1. Invoice#  Company  Site  InvoiceAmt   PmtAmt   PmtDue
  2. Invoice1     A          A1       2000            500        1500
  3. Invoice1     A          A2       4000           1000        3000
  4. Invoice 1    A          A3       1000           1000          0
  5. Invoice 2    B           B        3000           3000          0
  6.  
On my report, I would like to show two invoices on my report: - Company A has an Invoice1 with an Outstanding Balance $4,500 and Company B has an Invoice2 with an show total invoice amount is 0 (since it's only 2 invoices). I want to show this on my report. I was browsing around the internet and I came across a workaround method of doing this but it doesn't seem to be working for me. This is what I have done: -

I created a count query called qryPmtCount to count the number of invoice rows of each invoice based on my report's recordsource query: -
Expand|Select|Wrap|Line Numbers
  1. SELECT qryPayments.InvoiceNumber, Count(qryPayments.[InvoiceNumber]) AS N
  2. FROM qryPayments
  3. GROUP BY qryPayments.[InvoiceNumber];
  4.  
I created another new query called "qryPmtSum" in which I joined the "qryPmtCount" query to the original report query called qryPayments on the invoice number. I added all the fields from your original report query along with the count field, N, from the count query. Afterwards, I then changed the report's recordsource from your original query (qryPayments) to this new one.

In my report, I added the new count field N to the detail line, but setted its visible property to false (because I do not want to show how many invoice payments there are for that invoice). Finally, to get the true invoice value shown on each unbound invoice total, I changed the control source to: -
Expand|Select|Wrap|Line Numbers
  1. =SUM([PmtDue]/[N])
But the report is still not showing the expected results of only payment amounts for two invoice numbers: - Invoice1 and Invoice2. The report is still showing 4 line items: Invoice 1 repeating three times and Invoice 2 once.

Thank you in advance for your help
Sep 1 '15 #1

✓ answered by wirejp

Instead of using the approach described above, I used this query instead: -
Expand|Select|Wrap|Line Numbers
  1. SELECT qryPaymentPremiums.PremiumInvoiceNumber, qryPaymentPremiums.[ClientID], Sum(qryPaymentPremiums.NetPremiumAmt) AS SumOfNetPremiumAmt, Sum(qryPaymentPremiums.PremiumPmt) AS SumOfPremiumPmt, Sum([NetPremiumAmt]-[PremiumPmt]) AS PmtPrem
  2. FROM qryPaymentPremiums
  3. GROUP BY qryPaymentPremiums.PremiumInvoiceNumber, qryPaymentPremiums.[ClientID];

3 1369
wirejp
77 64KB
I got the issue resolved. Thanks
Sep 1 '15 #2
Rabbit
12,516 Expert Mod 8TB
Can you post your solution in case someone runs into the same problem?
Sep 2 '15 #3
wirejp
77 64KB
Instead of using the approach described above, I used this query instead: -
Expand|Select|Wrap|Line Numbers
  1. SELECT qryPaymentPremiums.PremiumInvoiceNumber, qryPaymentPremiums.[ClientID], Sum(qryPaymentPremiums.NetPremiumAmt) AS SumOfNetPremiumAmt, Sum(qryPaymentPremiums.PremiumPmt) AS SumOfPremiumPmt, Sum([NetPremiumAmt]-[PremiumPmt]) AS PmtPrem
  2. FROM qryPaymentPremiums
  3. GROUP BY qryPaymentPremiums.PremiumInvoiceNumber, qryPaymentPremiums.[ClientID];
Sep 2 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: tom | last post by:
Hi, I have built an Access DB for a child care business. Family table stores the Family info. Room the different room names, capacity etc. Price stores the various price codes and amounts. The...
13
by: Ron | last post by:
Hi all I'm deciding whether to use the PK also as an account number, invoice number, transaction number, etc that the user will see for the respective files. I understand that sometimes a...
3
by: barkarlo | last post by:
how can I create input mask for invoice number for an example 07-08000-427 where 07-08000 is constant and 427 is changes. I would like write only number who is changes.
1
by: lctking | last post by:
on an Excel spread sheet I have 3 columns of data - in column 1 are invoice numbers, in column 2 are amounts, and in column 3 are descriptions of charges i.e salary,supplies, etc - every invoice can...
1
by: gobblegob | last post by:
Hi guys i am trying to randomize 6 numbers into 6 textboxes up to the value of 60 without repeating a number but i dont know how an error handler would work for duplicate numbers any idea's? this...
21
by: palanidharma | last post by:
hi all, i am new to php.how to generate invoice number (EX:INV2008001) this format. plz reply me the code.... thanks palani
6
by: ConfusedMay | last post by:
Hi I need some helps in calculating the invoice amount in access 2003 report. Basically I have an access report that shows invoice#, invoice amount, payment amount, and payment date. The problem is...
5
by: chrisbenett | last post by:
Hi all, I want to create an invoice number that looks like "YYMMDD01" which will increment with 1 for each invoice. But the next day, it will need to start at one again. Example: Today:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.