As a newbe, I tried to receive the date of birth from a form in a local format: ddmmyyyy.
somewhere I messed up, but couldn't find a correct solution.
Can anybody tell me where I'm wrong and how to correct? Here's my code sofar:
Private Sub dtpGeboorteDatum_Exit(ByVal cancel As MSForms.ReturnBoolean)
If Left(dtpGeboorteDatum.Value, 2) > 31 Or Mid(dtpGeboorteDatum.Value, 3, 2) > 12 Then
dDate = DateSerial(Year(Date), Month(Date), Day(Date))
If Not dDate Like "########" Or Len(dDate) <> 8 Then
dDate = Mid(dDate, 5, 4) & "/" & Mid(dDate, 3, 2) & "/" & Left(dDate, 2)
If dDate <> dtpGeboorteDatum.Value Then dtpGeboorteDatum.Value = dDate
End If
formulier:
End Sub
somewhere I messed up, but couldn't find a correct solution.
Can anybody tell me where I'm wrong and how to correct? Here's my code sofar:
Private Sub dtpGeboorteDatum_Exit(ByVal cancel As MSForms.ReturnBoolean)
If Left(dtpGeboorteDatum.Value, 2) > 31 Or Mid(dtpGeboorteDatum.Value, 3, 2) > 12 Then
MsgBox "Incorrect dat: please enter as ddmmjjjj", vbCritical
dtpGeboorteDatum.Value = vbNullString
dtpGeboorteDatum.SetFocus
GoTo formulier
ElsedDate = DateSerial(Year(Date), Month(Date), Day(Date))
If Not dDate Like "########" Or Len(dDate) <> 8 Then
MsgBox "Incorrect dat: please enter as ddmmjjj"
dtpGeboorteDatum.SetFocus
GoTo formulier
End IfdDate = Mid(dDate, 5, 4) & "/" & Mid(dDate, 3, 2) & "/" & Left(dDate, 2)
If dDate <> dtpGeboorteDatum.Value Then dtpGeboorteDatum.Value = dDate
End If
formulier:
End Sub