fat controller
Slightly round the bend..
- Local time
- Today, 21:36
- Joined
- Apr 14, 2011
- Messages
- 758
I have a table (now stuffed full with data), which is serving its purpose quite nicely - however, someone has made a request for data from that table, but in a different way that has thrown me a bit of a curveball.
Each record contains a number of fields, but the key ones for this purpose will be:
SDYear (contains a four digit number to represent a calendar year)
EmployeeNumber (unique identifier for a member of staff)
NumAccidents (contains the number of accidents they have had, if any - null, if they have had none)
Isolating those staff who have not had an accident in a given year is dead easy (Where NumAccidents Is Null), however what I can't quite work out is how to isolate staff who have NEVER had an accident. Some of these records go back to the mid 1960's (I am not kidding!), with a record per year.
Just to complicate things that wee bit more, I would like to be able to pull a report showing all of these staff together, which I can then sort in order based on their start date.
Each person's history is dealt with on a continuous form which shows all of their records at the same time, so I did toy with the idea of totalling up the NumAccidents field, and then either putting the total into a field in a separate table (I could feasibly add a field into the Employees table) via VBA/SQL, but that would mean that each and every person's record would have to be revisited, and the code triggered somehow just to update this one field - - and there are literally thousands of staff...... you will understand my reluctance to do it this way.
Could this be done within a query?
Each record contains a number of fields, but the key ones for this purpose will be:
SDYear (contains a four digit number to represent a calendar year)
EmployeeNumber (unique identifier for a member of staff)
NumAccidents (contains the number of accidents they have had, if any - null, if they have had none)
Isolating those staff who have not had an accident in a given year is dead easy (Where NumAccidents Is Null), however what I can't quite work out is how to isolate staff who have NEVER had an accident. Some of these records go back to the mid 1960's (I am not kidding!), with a record per year.
Just to complicate things that wee bit more, I would like to be able to pull a report showing all of these staff together, which I can then sort in order based on their start date.
Each person's history is dealt with on a continuous form which shows all of their records at the same time, so I did toy with the idea of totalling up the NumAccidents field, and then either putting the total into a field in a separate table (I could feasibly add a field into the Employees table) via VBA/SQL, but that would mean that each and every person's record would have to be revisited, and the code triggered somehow just to update this one field - - and there are literally thousands of staff...... you will understand my reluctance to do it this way.
Could this be done within a query?