I have the following code to check if the formatting of the data being entered into the text field:
I have 60 other fields (txtTime2,txtTime3...txtTime60) that need to have the same validation check performed when they are updated. Is there a way to loop through multiple Private Subs or will I need to copy/paste the code and modify it for each individual field?
Code:
Private Sub txtTime1_AfterUpdate()
With txtTime1
If IsDate(.Value) Then
.Value = Format(.Value, "HH:MM AM/PM")
Else
MsgBox "Input time as HH:MM"
.Value = ""
Cancel = True
End If
End With
End Sub
I have 60 other fields (txtTime2,txtTime3...txtTime60) that need to have the same validation check performed when they are updated. Is there a way to loop through multiple Private Subs or will I need to copy/paste the code and modify it for each individual field?