We arrive at what I feel is a workable solution, or something relatively close, and you now wish to change your strategy. I really do not understand this logic.
vba to split duration in each hour and add record
Collapse
X
-
Attached is an example of how this would be done without VBA code. It only accounts for time ranges spanning 2 days. You would have to add more records to the time slots table to account for more days.Attached FilesComment
-
Dear ADezii
Sorry for the delayed reply. I was busy with some personal travelling. The solution is workable but only one issue I am having. When it capture "Start" and Finish" for the logout in next date, that particular entry "00:00" 00:59 or any time in tha next date, the Date should show the logout date. Because "Start" and "Finish" time is in the next date. Hope my explanation is clear. Please help me to resolve that.Comment
-
Dear ADezii
Thank you for the kind reply. I am attaching the same DB you have provided, but with manually adjusted expected results in the"PositionHrs " table. As you can see from the "MasterLogs " table, record 4 spans to 2 dates and in the expected results "PositionHr s" table the expected results are in record number 12 to 15. Hope that will give you a clear picture about what I am looking for. The login and logout fields doesnt need to be written to the "PositionHr s" table.Attached FilesComment
-
Right now, I absolutely see no easy method to accomplish what you have requested since it would involve 2 different Methods of displaying the Data, one for Time Slots in a single Day, and another for spanning Multiple Days. What I have done is to essentially run the same block of Code twice, catching first the single Day Time Slots and then Multiple Day Time Slots. This will display the Records in PositionHrs first by Single Day, then by Multiple Day and will not reflect the natural order of Records in MasterLogs. This is not really desirable and neither is the duplication of Code, but it is all that I can come up with at this point in time. As soon as I get more time to look at it, I'll give it another try. In any event, take a look at the Revised Demo and see what you think.Attached FilesComment
-
Dear ADezii
Thank you for the effort and patience you have shown. Instead of repeating the code block, is there any way we can while adding the record which has next day logout to have the date captured from the logout. But not for the time period 2300-2359 - That should have date as login date.
Other wise the date will show previous date for hours in next date.Comment
-
Dear ADezii
The date is based on login and logout. for each hour in a login date the duration need to be found. and if the login and logout is different dates, then upto time 2359 the duration will fall into login date. any duration after 2359 of the login date will be recorded for the logout date. an example is if login 01-Aug-17 2350 and logout 02-Aug-17 0015, then there will be 2 entries need to be added to PositionHrs. 1 entry for 01-Aug-17 2300-2359 with a duration of 10 minutes and 2nd entry for 02-Aug-17 for time period 0000-0059 with a duration of 15 minutes. Hope my explanation is not confusing you. Please helpComment
-
Changed the overall Logic with no Code Duplication and added a Log Date Field which would indicate spanning a Day. I feel as though we are very close now.
P.S. - See entries for Babe Ruth and Barney Rubble.Attached FilesComment
Comment