so i have an if statement that looks at two fields and checks whether they are in a 28 day period, if not then one of the fields are colored in red to highlight the problem
two questions,
in the sub form, it is a continous form, currently when the data is wrong and the field is colored, all the fields are colored the same, how can i just select the field with the incorrect date, as apose to all the fields whether they are wrong ir not.,
secondly, once the error has been fixed, how can i then clear the color from the fields?
here is my if statement so far
two questions,
in the sub form, it is a continous form, currently when the data is wrong and the field is colored, all the fields are colored the same, how can i just select the field with the incorrect date, as apose to all the fields whether they are wrong ir not.,
secondly, once the error has been fixed, how can i then clear the color from the fields?
here is my if statement so far
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim PeriodDate As Date
Dim WashDate As Date
PeriodDate = Me.Parent.txtPeriodCommence
WashDate = Me.txtWashDate
If WashDate > DateAdd("d", 28, PeriodDate) Then
MsgBox "Sorry, but the date you have entered is outside the period, please enter a date within 28 days of the period commencing date."
Me.txtWashDate.SetFocus
Me.txtWashDate.BackColor = vbRed
Cancel = True
End If
End Sub