RobinR
Robin Roelofsen
- Local time
- Today, 20:41
- Joined
- Apr 23, 2010
- Messages
- 8
Hi all,
I work for a company that sells access control systems to stores. Access data is stored in a MSSQL database, and I am assigned to build an Access frontend to extract this data and put it in nice reports
When an employee works in a store, he logs in (action), when he goes on a break, there is another action, etcetera. When the system is used correctly, the data shows something like:
1. Work In
2. Break In
3. Break Out
4. Break In
5. Break Out
6. Work Out
Calculating worktime is easy in this case: the time elapsed between record 1 and 6 minus the time between records 2 and 3 and records 4 and 5.
The problem starts when the employee does not select the correct actions during the day. His entries might end up looking like this:
1. 12:00 Work In
2. 15:00 Break In
3. 15:15 Break Out
4. 15:30 Break Out
5. 17:45 Break In
6. 18:30 Work Out
7. 20:00 Work Out
In this case, only the time between records 1 and 2 ( 3 hours) and records 4 and 5 (2.25 hours) are considered worktime. A Break Out should be followed by either a Break In or a Work Out, but not by another Break Out. Same goes for Work Out.
What I need is a way to find an action and look for the next record for that user and check that action. If the action is the same action as the one already found, the time of the first one is replaced by the next identical action, etcetera.
In the example, when Break In is found, the program should look for a Break Out. It finds that in record 3, so worktime starts again at 15:15. The next record however also shows Break Out, so the time should be replaced by 15:30, so worktime starts at that time now.
In the end, I want to calculate times worked in different departments. E.g. an employee in a supermarket might work 3 hours in the groceries department, 2 hour in dairy, etcetera. I want to be able to calculate the time worked per department.
I expect it will be some VBA function using If... Then... Else loops or Case statements, but I am at a loss here!
Any help or pointers is greatly appreciated!
I work for a company that sells access control systems to stores. Access data is stored in a MSSQL database, and I am assigned to build an Access frontend to extract this data and put it in nice reports

When an employee works in a store, he logs in (action), when he goes on a break, there is another action, etcetera. When the system is used correctly, the data shows something like:
1. Work In
2. Break In
3. Break Out
4. Break In
5. Break Out
6. Work Out
Calculating worktime is easy in this case: the time elapsed between record 1 and 6 minus the time between records 2 and 3 and records 4 and 5.
The problem starts when the employee does not select the correct actions during the day. His entries might end up looking like this:
1. 12:00 Work In
2. 15:00 Break In
3. 15:15 Break Out
4. 15:30 Break Out
5. 17:45 Break In
6. 18:30 Work Out
7. 20:00 Work Out
In this case, only the time between records 1 and 2 ( 3 hours) and records 4 and 5 (2.25 hours) are considered worktime. A Break Out should be followed by either a Break In or a Work Out, but not by another Break Out. Same goes for Work Out.
What I need is a way to find an action and look for the next record for that user and check that action. If the action is the same action as the one already found, the time of the first one is replaced by the next identical action, etcetera.
In the example, when Break In is found, the program should look for a Break Out. It finds that in record 3, so worktime starts again at 15:15. The next record however also shows Break Out, so the time should be replaced by 15:30, so worktime starts at that time now.
In the end, I want to calculate times worked in different departments. E.g. an employee in a supermarket might work 3 hours in the groceries department, 2 hour in dairy, etcetera. I want to be able to calculate the time worked per department.
I expect it will be some VBA function using If... Then... Else loops or Case statements, but I am at a loss here!
Any help or pointers is greatly appreciated!