Greetings,
I am creating a "stoplight" type report that is based on the number of days between dates, the field will be highlighted in red, yellow, or green. I am able to change the background color on the textbox, but each subsequent record is set to the color as determined by the first record. Is there a way to do this for each record? I am using access 97. My code is something like this (I'm going off of memory as I left my code at work):
Dim mydate1 As Date, mydate2 As Date
Dim lngRed As Long, lngGreen As Long
db = DAO.database
rs = DAO.recordset
Set db = connect.database()
Set rs = db.connect("queryname")...can't remember exactly, its been a long day
rs.movefirst
Do until rs.eof
If mydate1 - mydate2 >3 Then
Me.dateofinterest.backcolor = lngRed
Else
Me.dateofinterest.backcolor = lngGreen
End If
rs.movenext
Loop
rs.close
set db = nothing
set rs = nothing
Anyhow, the code seems to work as is and is set to the form open event (I also tried form load), but it sets every text box to the color based on the if statement for the first record. I have also tried creating a bunch of subforms, but each opens in the first record. I realize that since each textbox is named the same thing in the form, that is why it is doing it.
Does anyone know of a different/better/easier way in access 97?