poucedeleon
Registered User.
- Local time
- Today, 10:25
- Joined
- Jun 6, 2008
- Messages
- 19
Record Sort using Time/Date, that crosses midnight
The purpose of this application is to log Arresting officers coming into our facility. The Booking Assistant logs the time arrived, the officer’s name, the prisoner’s name, the time they give us their paperwork and the time they leave.
The problem I am having is I need to be able to do a sort by time so the Booking Assistant can look at the bookings by shift (This is a continuous form). The graveyard shift starts at 00:00hrs but the count for their shift starts at 23:00hrs the previous day and ends at 05:00hrs. I have not been able to create an expression to handle this.
The form has a field [BookedDate] (Formatted Date() ), and there are three time related fields that the Booking Assistants enter “TimeIn”, “PaperReceived” and “TimeOut”
In the Form Header I have an Option Group that will be used to sort the records by shift. I am using VBA code to make this work.
Since I could not figure out how to make a calculated field work, as a test I added a “bound” combo box (Value List) with the three shifts. When you select the shift from the combo box the sort works fine, but this is an extra step and a number of times the assistants have selected the wrong shift.
I would like to have a field (that will be hidden) that returns Graves, Days or Swings based on the time in “TimeIn” or the “Book Date”. I can change this to General Date so it displays Date/Time. (I right-click on this field to sort by date after sorting by Shift.) I will also be creating a report that will be printed at the end of each shift that will show who was booked during the shift. If someone could tell me how to proceed I would be so happy. Been stuck here for a while. Thanks
The purpose of this application is to log Arresting officers coming into our facility. The Booking Assistant logs the time arrived, the officer’s name, the prisoner’s name, the time they give us their paperwork and the time they leave.
The problem I am having is I need to be able to do a sort by time so the Booking Assistant can look at the bookings by shift (This is a continuous form). The graveyard shift starts at 00:00hrs but the count for their shift starts at 23:00hrs the previous day and ends at 05:00hrs. I have not been able to create an expression to handle this.
The form has a field [BookedDate] (Formatted Date() ), and there are three time related fields that the Booking Assistants enter “TimeIn”, “PaperReceived” and “TimeOut”
In the Form Header I have an Option Group that will be used to sort the records by shift. I am using VBA code to make this work.
Code:
Private Sub cmdFilterRecords_Click()
'Variable to hold filtered SQL string
Dim strFilterSQL As String
'Set default record source of form
'Const strSQL = "SELECT tblStudentInformation.strShift,tblStudentInformation.strStudentID,tblStudentInformation.strFirstName,tblStudentInformation.strLastName,tblStudentInformation.strCity, tblStudentInformation.strCounty, tblStudentInformation.dtmEnrolled, tblStudentInformation.strSigninTime FROM tblStudentInformation"
Select Case Me!optFilterBy
'Filter record source dependant on option checked
Case 1
strFilterSQL = strSQL & " Where [strShift] = 'Graveyard';"
Case 2
strFilterSQL = strSQL & " Where [strShift] = 'Dayshift';"
Case 3
strFilterSQL = strSQL & " Where [strShift] = 'Swingshift';"
'If filter applied with no option selected use default record source
Case Else
strFilterSQL = strSQL & ";"
End Select
' Set record source with filtered SQL
Me.RecordSource = strFilterSQL
Me.Requery
End Sub
Since I could not figure out how to make a calculated field work, as a test I added a “bound” combo box (Value List) with the three shifts. When you select the shift from the combo box the sort works fine, but this is an extra step and a number of times the assistants have selected the wrong shift.
I would like to have a field (that will be hidden) that returns Graves, Days or Swings based on the time in “TimeIn” or the “Book Date”. I can change this to General Date so it displays Date/Time. (I right-click on this field to sort by date after sorting by Shift.) I will also be creating a report that will be printed at the end of each shift that will show who was booked during the shift. If someone could tell me how to proceed I would be so happy. Been stuck here for a while. Thanks
Attachments
Last edited: