I have table for Users
that contains a budget for training
ID | UserID | FName | SName | Dept | Budget
1 | 1 | John | Smith | CS | 1000
2 | 2 | Ian | Caine | CS | 2500
3 | 3 | Jane | Kelly | ED | 1000
4 | 1 | John | Smith | EQ | 1000
5 | 2 | Ian | Caine | EQ | 2500
6 | 3 | Jane | Kelly | CS | 1000
I then have another table Courses
that stores the course they have taken;
ID | UserID | Course | Date | Dept |Cost
1 | 1 | CS01 | 1/4/18 | CS | 100
2 | 2 | CS01 | 1/4/18 | CS | 100
3 | 1 | CS02 | 10/4/18 | CS | 75
4 | 2 | CS02 | 10/4/18 | CS | 75
5 | 1 | CS01 | 1/4/18 | EQ | 100
I want to create a form with the the User
information at the top and a subform with the Courses
at the bottom, something like
UserID | FName | SName | Dept | Budget
1 | John | Smith | CS | 1000
subfrm
Course | Date | Cost | Balance Remaining
CS01 | 1/4/18 | 100 | 900
CS02 | 10/4/18 | 75 | 825
[UPDATE] I am stuck with the underlying query for the subform, the following is the SQL I am playing with;
SELECT USerID, Amount,
(SELECT Sum(tbl_Courses.Cost) AS Total
FROM tbl_Courses
WHERE tbl_Courses.ID <= t1.ID) AS Total
FROM tbl_Courses AS T1
But this gives me a complete running total rather than a running total by UserID and Dept.