Changing backround color

Dante1980

Registered User.
Local time
Today, 04:58
Joined
Mar 20, 2006
Messages
11
Hi everybody,

I'm trying to make the backround color of a text box "prova" (short date value) changing according to the values of other two different text boxes "StartDate" and "EndDate" (both are short date values).
I'd like the backround of prova to be blue if its value is between StartDate value and EndDate value.
So in the code builder I made this function:

Private Sub prova_AfterUpdate()

If Me.prova.Value > Me.StartDate.Value & Me.prova.Value < Me.EndDate.Value Then

Me.[prova].BackColor = vbBlue

Else
Me.[prova].BackColor = vbWhite
End If

End Sub


Is that correct?
Thank a slot for your help :confused:
 
make sure prova uses the same data type/format

try prova.BackColor = vbBlue
 
Hi Dante

I suspect that your field will always be blue...

You need to change your code to the following to get it to work.

Code:
Private Sub prova_AfterUpdate()

If prova > StartDate [COLOR="blue"]AND[/COLOR] prova < EndDate Then
   prova.BackColor = vbBlue
Else
   prova.BackColor = vbWhite
End If

End Sub

If the fields are unbound, Access may treat these dates as text, so you will need to change them to dates using the CDATE(...) function.

Hope this helps
Regards
Rod
 

Users who are viewing this thread

Back
Top Bottom