I have a date textbox which is updated when another combobox is changed. When there no corresponding value for date, it automatically posts todays date in the date textbox.
Next to the date textbox I have a "X" which shows when the data is not valid. Here is the code for the date textbox
The problem is the 'X' is still appearing initially when the date is shown in the textbox despite matching all the criteria. If I then click in the textbox, delete a character and then retype the same character the 'X' disappears.
Any idea why this isn't working. I have a similar thing for Time, which works fine.
If you need any further information, or I haven't been clear enough defining the problem then let me know
Next to the date textbox I have a "X" which shows when the data is not valid. Here is the code for the date textbox
Code:
Private Sub txtDateOfAlert_Change()
txtTimeOfAlert.Value = ""
If Not txtDateOfAlert.Value Like "##[/]##[/]####" Then
imgCross2.Visible = True
Else
If IsDate(txtDateOfAlert) Then
If CDate(txtDateOfAlert.Value) < CDate(txtDateOfAccident.Value) Or _
(txtDateOfAlert.Value) > Format(Date, "dd/mm/yyyy") Then
imgCross2.Visible = True
Else
imgCross2.Visible = False
End If
Else
imgCross2.Visible = True
End If
End If
'Specifies format of DateOfAlert
'Checks whether DateOfAlert value is a valid date
'Checks that DateOfAlert is after DateOfAccident and not in the future
'Defines Visibility
End Sub
The problem is the 'X' is still appearing initially when the date is shown in the textbox despite matching all the criteria. If I then click in the textbox, delete a character and then retype the same character the 'X' disappears.
Any idea why this isn't working. I have a similar thing for Time, which works fine.
If you need any further information, or I haven't been clear enough defining the problem then let me know
Last edited: