Hi
I'm wondering if anyone can help me I've tried various codes to try and get a validation to work.
Basically what I want to do is change the background colour of a form based on the date in a field. The date in the field is based on the date +18 years, I'm trying to highlight a page if the person identified is under 18 and then a secondary iselse based on another box being ticked and a third elseif if both conditions are met and failing all that a default (no colour).
This is what I have for the current change on the tick box
Private Sub Form_Current()
If [Forms]![Client Demographics]![Alert] = True Then
[Forms]![Client Demographics].Detail.BackColor = vbRed
Else
[Forms]![Client Demographics].Detail.BackColor = vbWhite
End If
End Sub
This is what I tried for the date and Alert conditions:-
Private Sub Form_Current()
If [Forms]![Client Demographics]![Alert] = True Then
[Forms]![Client Demographics].Detail.BackColor = vbRed
ElseIf
[Forms]![Client Demographics]![DOB] =>Date() and <Date()-6570 Then
[Forms]![Client Demographics].Detail.BackColor = vbYellow
Else
[Forms]![Client Demographics].Detail.BackColor = vbWhite
End If
End Sub
I can't get the date part to work and it is frustrating me a bit :banghead:
Any help you can shed on my lack of experience would be awesome.
Many thanks in advance
I'm wondering if anyone can help me I've tried various codes to try and get a validation to work.
Basically what I want to do is change the background colour of a form based on the date in a field. The date in the field is based on the date +18 years, I'm trying to highlight a page if the person identified is under 18 and then a secondary iselse based on another box being ticked and a third elseif if both conditions are met and failing all that a default (no colour).
This is what I have for the current change on the tick box
Private Sub Form_Current()
If [Forms]![Client Demographics]![Alert] = True Then
[Forms]![Client Demographics].Detail.BackColor = vbRed
Else
[Forms]![Client Demographics].Detail.BackColor = vbWhite
End If
End Sub
This is what I tried for the date and Alert conditions:-
Private Sub Form_Current()
If [Forms]![Client Demographics]![Alert] = True Then
[Forms]![Client Demographics].Detail.BackColor = vbRed
ElseIf
[Forms]![Client Demographics]![DOB] =>Date() and <Date()-6570 Then
[Forms]![Client Demographics].Detail.BackColor = vbYellow
Else
[Forms]![Client Demographics].Detail.BackColor = vbWhite
End If
End Sub
I can't get the date part to work and it is frustrating me a bit :banghead:
Any help you can shed on my lack of experience would be awesome.
Many thanks in advance