Hi people
I try to change the color of a data field on a form depending on weekday, so it would be friendlier and easier to manage.
I am talking about a form with like 10-20 records. Now, its working but instead of changinf just the field that I want it changes all. I wrote this test code, maybe you see what's wrong with it:
Why cant I do this directly from conditional formating saying something like: if the value of the field =vbmonday then blabla
Sub colours()
Dim lngRed As Long, lngYellow As Long, lngWhite As Long
Dim db As DAO.Database
Dim s As DAO.QueryDef
Dim r As DAO.Recordset
Set db = CurrentDb
lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
Set r = Forms!frmplanclient.Form.Recordset
r.MoveFirst
If r.EOF = False Then
Do While r.EOF = False
If Weekday(r(5)) = 1 Then 'or vbmonday or something
Me!dateplan.BackColor = lngYellow
End If
r.MoveNext
'??
Me.dateplan.BackColor = lngWhite
Loop
End If
r.MoveFirst
Set r = Nothing
End Sub
I try to change the color of a data field on a form depending on weekday, so it would be friendlier and easier to manage.
I am talking about a form with like 10-20 records. Now, its working but instead of changinf just the field that I want it changes all. I wrote this test code, maybe you see what's wrong with it:
Why cant I do this directly from conditional formating saying something like: if the value of the field =vbmonday then blabla
Sub colours()
Dim lngRed As Long, lngYellow As Long, lngWhite As Long
Dim db As DAO.Database
Dim s As DAO.QueryDef
Dim r As DAO.Recordset
Set db = CurrentDb
lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
Set r = Forms!frmplanclient.Form.Recordset
r.MoveFirst
If r.EOF = False Then
Do While r.EOF = False
If Weekday(r(5)) = 1 Then 'or vbmonday or something
Me!dateplan.BackColor = lngYellow
End If
r.MoveNext
'??
Me.dateplan.BackColor = lngWhite
Loop
End If
r.MoveFirst
Set r = Nothing
End Sub