I'd have thought a query along these lines, which returns all clients and the
sum of all time card billing amounts and expenses in relation to each
client's projects less the sum of all payments in relation to the project,
where this is more than zero, would give the required results. You could if
you wished break it down by project by joining the projects table to the
Clients table in the outer query and correlating the subqueries to the outer
query on ProjectID rather than ClientID.
SELECT CompanyName,
(SELECT SUM(ExpenseAmount)
FROM [Time Card Expenses], Projects
WHERE [Time card Expenses].ProjectID = Projects.ProjectID
AND Projects.ClientID = Clients.ClientID)
+(SELECT SUM(BillableHours*BillingRate)
FROM [Time card Hours], Projects
WHERE [Time card Hours].ProjectID = Projects.ProjectID
AND Projects.ClientID = Clients.ClientID)
-(SELECT SUM(PaymentAmount)
FROM Payments, Projects
WHERE Payments.ProjectID = Projects.ProjectID
AND Projects.ClientID = Clients.ClientID) AS BalanceOutstanding
FROM Clients
WHERE (SELECT SUM(ExpenseAmount)
FROM [Time Card Expenses], Projects
WHERE [Time card Expenses].ProjectID = Projects.ProjectID
AND Projects.ClientID = Clients.ClientID)
+(SELECT SUM(BillableHours*BillingRate)
FROM [Time card Hours], Projects
WHERE [Time card Hours].ProjectID = Projects.ProjectID
AND Projects.ClientID = Clients.ClientID)
-(SELECT SUM(PaymentAmount)
FROM Payments, Projects
WHERE Payments.ProjectID = Projects.ProjectID
AND Projects.ClientID = Clients.ClientID) > 0;
Ken Sheridan
Stafford, England
Jason said:
Hello. I am trying to create a report or a query to spit out a report
of what clients still have outstanding balances (and the balance) . I
have tried to past the client subform into a report, and all I get is
'#NAME?' in the 'Amount Due' column.
Anyone get something like that going in this template?
Thanks in advance,
-J