I have two tables in my Access 2K db: tblData, and tblDateRange.
TblData's colums are made up of fname and lname columns, and then a series of dates.
My query pulls all of the rows from the tblData where any of the date columns fall between the two dates listed in the tblDateRange table. (Sdate and Edate).
My report lists all the rows from the query.
Here is my problem: How do I programatically (using VB) change the backcolor of the text boxes on the report for those dates that fall within the range?
I've managed to do it using the conditional format menu, but I would prefer to do it using VB.
I have tried various combinations of using Dlookup that compare to what is in the conditional format screen, but to no avail. I am assuming that whatever the code is, it should be in the ON Format event of the report, right?
I have tried something like this, but no luck:
*************
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dteSdate As Date
Dim dteEdate As Date
dteSdate = DLookup("[sdate]", "tblDateRange"
dteEdate = DLookup("[edate]", "tblDateRange"
If [1_year] >= dteSdate And [1_year] <= dteEdate Then
[1_year].BackColor = vbBlue
End If
End Sub
***********
([1_year] is the name of one of the textboxes.)
I have also tried something along the lines of "if [1_year] between dlookup("[sdate]","tbldata","tbldaterange" And dlookup("[sdate]","tbldata","tbldaterange" Then
[1_year].backcolor = vblue
end if"
That I know that isn't close to the right syntax.
What is the proper way to do this?
Thanks!
TblData's colums are made up of fname and lname columns, and then a series of dates.
My query pulls all of the rows from the tblData where any of the date columns fall between the two dates listed in the tblDateRange table. (Sdate and Edate).
My report lists all the rows from the query.
Here is my problem: How do I programatically (using VB) change the backcolor of the text boxes on the report for those dates that fall within the range?
I've managed to do it using the conditional format menu, but I would prefer to do it using VB.
I have tried various combinations of using Dlookup that compare to what is in the conditional format screen, but to no avail. I am assuming that whatever the code is, it should be in the ON Format event of the report, right?
I have tried something like this, but no luck:
*************
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dteSdate As Date
Dim dteEdate As Date
dteSdate = DLookup("[sdate]", "tblDateRange"
dteEdate = DLookup("[edate]", "tblDateRange"
If [1_year] >= dteSdate And [1_year] <= dteEdate Then
[1_year].BackColor = vbBlue
End If
End Sub
***********
([1_year] is the name of one of the textboxes.)
I have also tried something along the lines of "if [1_year] between dlookup("[sdate]","tbldata","tbldaterange" And dlookup("[sdate]","tbldata","tbldaterange" Then
[1_year].backcolor = vblue
end if"
That I know that isn't close to the right syntax.
What is the proper way to do this?
Thanks!