Dale Brown
New Member
Code:
Private Sub Txt_Date_Afterupdate()
Dim tString As String
With Txt_Date
'Check if user put in a colon or not
If InStr(1, .Value, ":", vbTextCompare) = 0 Then
'If not, make string 4 digits and insert colon
tString = Format(.Value, "0000")
tString = Left(tString, 2) & ":" & Right(tString, 2)
Txt_Date.Value = Format(TimeValue(tString), "HH:MM") ' this line comes up as error 'type mismatch
Else
'Otherwise, take value as given
.Value = Format(.Value, "hh:mm")
End If
End With
End Sub
All fixed. Had wrong TxtBox Name
Last edited by a moderator: