I'm trying to create a form that has a running total of the amount an organisation has been invoiced. 1 table (Database) consists of everything I've invoice out. The fields this table has is the Organisation code, name and amounts among many others.
I also have another table (Orgs) that is a comprehensive list of organisation codes, name and a blank field (Organisation_Total).
I've created a form whose Record Source is Orgs. My aim is to use a SQL Statement to populate the blank Total field automatically upon opening it, however I seem to be having some difficulty. I've tried multiple ways of doing it and I have the feeling I'm missing something simple.
The code I have so far is:
Expand|Select|Wrap|Line Numbers
- SELECT Orgs.Org_Code as Org_Code, Orgs.Org_Name as Org_Name, case when Database.Org_Code=Orgs.Org_Code then Sum(Total_Invoice_Amount) AS Org_Total else " "
- FROM Database
- INNER JOIN Orgs ON Orgs.Org_Code = Database.Org_Code
Thanks
Sunny