I had a quick search but couldnt find what I was looking for ,
I have a date field called txtDateReceived and another date called txtDateAllocated. I have these date inorder to calculate the no of cases have been allocate greater than 3 days. I have notice that some staff are failed to record the Date received.
What I would like is for the form to check to see if txtDateReceived is not null before txtDAteAllocated can be entered or if any other field is started to be filled in. The below code work Ok but only works when the record is attempted to be save.
Ive come up with this after a little search. I thought I would share it in case others would like to used it. Place it on before update event on the form.
If IsNull(Me.[txtDateAllegReceived]) Then
Me.[txtDateAllegReceived].SetFocus
MsgBox "You must enter the IMU Allegation received Date", , "Missing Data"
Cancel = True
Exit Sub
End If
'make sure the second Date is filled out
If IsNull(Me.[txtDateAllocated]) Then
Me.[txtDateAllocated].SetFocus
MsgBox "You must enter the Date Allocated to Investigations", , "Missing Data"
Cancel = True
Exit Sub
End If
'make sure the second Date is >= Date 1
If Me.[txtDateAllocated] < Me.[txtDateAllegReceived] Then
Me.[txtDateAllocated].SetFocus
MsgBox "The Date Allocated must greater or equal to Date received >= " & Me.[txtDateAllegReceived], , "Invalid Data"
Cancel = True
Exit Sub
End If
End Sub
I have a date field called txtDateReceived and another date called txtDateAllocated. I have these date inorder to calculate the no of cases have been allocate greater than 3 days. I have notice that some staff are failed to record the Date received.
What I would like is for the form to check to see if txtDateReceived is not null before txtDAteAllocated can be entered or if any other field is started to be filled in. The below code work Ok but only works when the record is attempted to be save.
Ive come up with this after a little search. I thought I would share it in case others would like to used it. Place it on before update event on the form.
If IsNull(Me.[txtDateAllegReceived]) Then
Me.[txtDateAllegReceived].SetFocus
MsgBox "You must enter the IMU Allegation received Date", , "Missing Data"
Cancel = True
Exit Sub
End If
'make sure the second Date is filled out
If IsNull(Me.[txtDateAllocated]) Then
Me.[txtDateAllocated].SetFocus
MsgBox "You must enter the Date Allocated to Investigations", , "Missing Data"
Cancel = True
Exit Sub
End If
'make sure the second Date is >= Date 1
If Me.[txtDateAllocated] < Me.[txtDateAllegReceived] Then
Me.[txtDateAllocated].SetFocus
MsgBox "The Date Allocated must greater or equal to Date received >= " & Me.[txtDateAllegReceived], , "Invalid Data"
Cancel = True
Exit Sub
End If
End Sub
Last edited: