What I need to do is add this code
In order to check that the date entered is not in the future, to this code which has various other arguments within it.
I can't figure out where to put it in, or if indeed it's needed multiple times. Wherever I seem to try it I seem to either break the code or negate one of the other arguments.
Any help would be greatly appreciated
Code:
If CDate(txtDateOfAccident.Value) > Format(Date, "dd/mm/yyyy") Then
imgCross2.visible = False
End If
In order to check that the date entered is not in the future, to this code which has various other arguments within it.
Code:
Private Sub txtDateOfAccident_Change()
If Not txtDateOfAccident.Value Like "##[/]##[/]####" Then
imgCross2.Visible = True
'Specifies the format of the textbox
Else:
If Mid(txtDateOfAccident.Value, 4, 2) < 13 And Mid(txtDateOfAccident.Value, 4, 2) > 0 Then
If Mid(txtDateOfAccident.Value, 4, 2) = "04" Or Mid(txtDateOfAccident.Value, 4, 2) = "06" Or Mid(txtDateOfAccident.Value, 4, 2) = "09" Or Mid(txtDateOfAccident.Value, 4, 2) = "11" Then
If Left(txtDateOfAccident.Value, 2) > 30 Or Left(txtDateOfAccident.Value, 2) < 1 Then
imgCross2.Visible = True
Else: imgCross2.Visible = False
End If
'Checks if the month of the date is a 30 day month, and if valid removes image
Else:
If Mid(txtDateOfAccident.Value, 4, 2) = "02" Then
If ((Mid(txtDateOfAccident.Value, 7, 4) \ 4) * 4) = ((Mid(txtDateOfAccident.Value, 7, 4) / 4) * 4) Then
If Left(txtDateOfAccident.Value, 2) > 29 Or Left(txtDateOfAccident.Value, 2) < 1 Then
imgCross2.Visible = True
Else: imgCross2.Visible = False
End If
'Checks if the month of the date is Febuary and what to do if it is a leap year, and if valid removes image
Else:
If Left(txtDateOfAccident.Value, 2) > 28 Or Left(txtDateOfAccident.Value, 2) < 1 Then
imgCross2.Visible = True
Else: imgCross2.Visible = False
End If
End If
'Specifies what to do if it's not a leap year, and if valid removes image
Else:
If Left(txtDateOfAccident.Value, 2) <= 31 And Left(txtDateOfAccident.Value, 2) > 0 Then
imgCross2.Visible = False
Else: imgCross2.Visible = True
'Specifies what to do if the month is a 31 day month, and if valid removes image
End If
End If
End If
Else: imgCross2.Visible = True
'Specifies that the month value must be between 1 and 12
End If
End If
End Sub
I can't figure out where to put it in, or if indeed it's needed multiple times. Wherever I seem to try it I seem to either break the code or negate one of the other arguments.
Any help would be greatly appreciated