I have a form with 2 date fields which have some formatting options in the VBA code.
When I put in a date like 10/08/2018 in the form... when it puts the date in to the corresponding cell on submission, it's switching the date to 08/10/2018.
I've formatted the cells to dd/mm/yyyy and the code in the VBA is:
Any ideas on how to stop the numbers from switching please?
When I put in a date like 10/08/2018 in the form... when it puts the date in to the corresponding cell on submission, it's switching the date to 08/10/2018.
I've formatted the cells to dd/mm/yyyy and the code in the VBA is:
Code:
Private Sub CommandButton1_Click() With DOBTextBox
.Value = dDate
.NumberFormat = "dd/mm/yyyy"
End With
End Sub
Private Sub DOBTextBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.DOBTextBox
If Len(.Text) > 0 Then
If Not .Text Like "##/##/####" Then
MsgBox "Invalid DOB date format" & Chr(10) & "Please re-enter as dd/mm/yyyy", vbCritical, "Invalid Format"
Cancel = True
Else
dDate = DateValue(.Text)
End If
End If
End With
End Sub
Private Sub CommandButton2_Click()
With SessionsBox
.Value = dDate2
.NumberFormat = "dd/mm/yyyy"
End With
End Sub
Private Sub SessionsBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.SessionsBox
If Len(.Text) > 0 Then
If Not .Text Like "##/##/####" Then
MsgBox "Invalid Session date format" & Chr(10) & "Please re-enter as dd/mm/yyyy", vbCritical, "Invalid Format"
Cancel = True
Else
dDate2 = DateValue(.Text)
End If
End If
End With
End Sub
Any ideas on how to stop the numbers from switching please?