Hi Roy,
Thank you for your assistance.
Hopefully you might be able to address a further issue. I inserted the code you provided then I got an error on another piece of code 'Compile error: Ambiguous name detected:tbx8_Exit. As you can see in the code below there are three messages associated with date fields, two are regarding the date format and the other is the piece of code you greatfully sent me regarding end date before start date. I have highlighted the bit of code that gets highlighted with the error.
Also, when I entered your code and ran the userform it doesn't allow me the opportunity to change the date, instead it just closes the userform.
I would be in your debt in you can assist.
'Checks that the user has entered the correct date format for text box 1
Private Sub tbx1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strDate As String
strDate = tbx1.Text
If Not IsDate(strDate) Then
MsgBox "Your date format is incorrect" & vbCrLf & "Enter a date as dd/mm/yyyy", _
vbOKOnly + vbExclamation
Cancel = True
End If
End Sub
'Checks that the user hasn't entered a Case Resolved Date with an earlier vale than Date Referral received
Private Sub tbx8_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me
If Not IsDate(.tbx8.Value) Then
MsgBox "Please enter a valid date"
.tbx8.Value = Empty
ElseIf CDate(.tbx8.Value) < .tbx1.Value Then
MsgBox "Case Resolved Date cannot be earlier than Referral Received Date"
.tbx8.Value = Empty
End If
End With
End Sub
'Checks that the user has entered the correct date format for text box 8
Private Sub tbx8_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strDate As String
strDate = tbx8.Text
If Not IsDate(strDate) Then
MsgBox "Your date format is incorrect" & vbCrLf & "Enter a date as dd/mm/yyyy", _
vbOKOnly + vbExclamation
Cancel = True
End If
End Sub