R
Rodney
Could I please have some help with this code.
I have the below code so far but it don't do what I would like.
I want it to check if there are [RosterDate] bewteen Me!LeaveStartDate and
Me!LeaveEndDate
but I also want to include the first day of leave LeaveStartDate and the
last day of leave LeaveEndDate not just dates between them
and if there are [RosterDate] within that period then display the message.
Private Sub TrainerID_BeforeUpdate(Cancel As Integer)
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblRoster", dbOpenDynaset)
If rst![TrainerID] = Me!TrainerID Then
If rst![RosterDate] >= Me!LeaveStartDate Then
If rst![RosterDate] <= Me!LeaveEndDate Then
Cancel = True
MsgBox "The trainer is rostered on for " & rst![RosterDate]
& vbCrLf & _
"please Remove trainer from roster first."
End If
End If
End If
End Sub
Thank you
Rodney
I have the below code so far but it don't do what I would like.
I want it to check if there are [RosterDate] bewteen Me!LeaveStartDate and
Me!LeaveEndDate
but I also want to include the first day of leave LeaveStartDate and the
last day of leave LeaveEndDate not just dates between them
and if there are [RosterDate] within that period then display the message.
Private Sub TrainerID_BeforeUpdate(Cancel As Integer)
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblRoster", dbOpenDynaset)
If rst![TrainerID] = Me!TrainerID Then
If rst![RosterDate] >= Me!LeaveStartDate Then
If rst![RosterDate] <= Me!LeaveEndDate Then
Cancel = True
MsgBox "The trainer is rostered on for " & rst![RosterDate]
& vbCrLf & _
"please Remove trainer from roster first."
End If
End If
End If
End Sub
Thank you
Rodney