I want to be able to auto fill a text box that holds a date depending on what is entered. All is working OK except when I try to auto fill when only the day has been entered. If only the day is entered (d or dd) the auto fill doesn't work. Below is the code i'm using. Can anyone offer any suggestions?
Code:
Private Sub txtDate_LostFocus()
Dim DayOnly As String

If txtDate = Format(txtDate, "dd/mm/yyyy") Or txtDate = Format(txtDate, "dd/mm/yy") _
Or txtDate = Format(txtDate, "d/mm/yyyy") Or txtDate = Format(txtDate, "d/mm/yy") _
Or txtDate = Format(txtDate, "dd/m/yyyy") Or txtDate = Format(txtDate, "dd/m/yy") _
Or txtDate = Format(txtDate, "d/m/yyyy") Or txtDate = Format(txtDate, "d/m/yy") Then
txtDate = Format(txtDate, "d/mm/yyyy")
ElseIf txtDate = Format(txtDate, "dd") Or txtDate = Format(txtDate, "d") Then
DayOnly = txtDate
txtDate = DayOnly & "/" & CurrentMonth & "/" & CurrentYear
txtDate = Format(txtDate, "d/mm/yyyy")
ElseIf txtDate = Format(txtDate, "d/m") Or txtDate = Format(txtDate, "dd/m") _
Or txtDate = Format(txtDate, "d/mm") Or txtDate = Format(txtDate, "dd/mm") Then
DayOnly = txtDate
txtDate = DayOnly & "/" & CurrentYear
txtDate = Format(txtDate, "d/mm/yyyy")
End If
End Sub