Hi everyone,
I am new to using Access and have managed to figure out some things myself, but this has got me stumped.
I have built a database for tracking utilities (gas and electricity) invoice information for a portfolio of properties that the company I work for manage on our clients' behalf.
One of the things I need to track if the date of the last accurate invoice for each property and the logic I have built so far is as follows:
SELECT tblInvoiceData.strSiteName, Max(tblInvoiceData.dtmBillToDate) AS MaxOfdtmBillToDate
FROM tblInvoiceData, QryUtilities
WHERE (((tblInvoiceData.strFuelType)="Electricity") AND ((QryUtilities.ysnZTP)=True) AND ((QryUtilities.ysnLiveProperty)=True) AND ((QryUtilities.ysnUtilitiesAgreement)=True) AND ((tblInvoiceData.strR1ReadingType)="Actual"))
GROUP BY tblInvoiceData.strSiteName
ORDER BY Max(tblInvoiceData.dtmBillToDate) DESC;
"tblInvoiceData" is a table which contains all invoicing information and the relevant fields are as follows:
- strSiteName: The name of each of the sites
- dtmBillToDate: The date the bill goes up to
- strFuelType: The type of fuel
- strR1ReadingType: The type of meter reading (whether it is actual/estimated)
The logic works as far as it is successfully identifying the last bill date for each site where an actual meter reading was used. Where it is complicated, however, is that some sites have multiple meters. I need the query to tell me if the meter reading type for ALL of the meters associated with the site have been billed to actual meter readings, as if just one of them is estimated, the query will not do what I need it to do.
There is another column within "tblInvoiceData" called "intMPxN" which identifies the meter that the bill is based on.
Can anyone help with how I can perform this check in my query please?
Thanks in advance.