change color of detail when filter is applied

G

Guest

When a filter has been applied, I would like the detail background color to
change so they know they are looking at a filtered dataset. I tried the code
below, but all that changes is the filter by form screen BEFORE they apply
the filter. I need it to change color after they apply the filter. What am
I doing wrong? Thanks in advance!

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me.Detail.BackColor = -2147483633
End Sub

Private Sub Form_Filter(Cancel As Integer, FilterType As Integer)
Me.Detail.BackColor = 255
End Sub
 
F

fredg

When a filter has been applied, I would like the detail background color to
change so they know they are looking at a filtered dataset. I tried the code
below, but all that changes is the filter by form screen BEFORE they apply
the filter. I need it to change color after they apply the filter. What am
I doing wrong? Thanks in advance!

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me.Detail.BackColor = -2147483633
End Sub

Private Sub Form_Filter(Cancel As Integer, FilterType As Integer)
Me.Detail.BackColor = 255
End Sub

Just use the ApplyFilter event.

If Me.Section(0).BackColor = -2147483633 Then
Me.Section(0).BackColor = 255
Else
Me.Section(0).BackColor = -2147483633
End If

I'm not sure which color you wish when the filter is applied.
The above colors the detail section Red when applied and returns it to
the normal color when filter is off.
 
M

Max Brassfield

I was messing around with a report for home the tracks Keno Numbers and wanted the number on my report to change color
when the number hit and found this to work quite well rather than setting the way you are doing. Doing it that way
would work for the first one but the remaining numbers would not do anything. The first section compares the first 2
numbers to the remaining of all 80 numbers. The Ctl1 is the #1 of 80 compared to COL1 one of five drawn and would turn
red if matched. The Case else made it stay white. Anyway it worked for me. The most frustrating thing I have found
with Access is figuring out how to ask the question to get the answer I want

Found it on this website http://www.lebans.com/toc.htm

Max
Fernley NV

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Select Case Me.Ctl1

Case Is = Me.COL1
Me.Ctl1.BackColor = 14737632

Case Is = Me.COL2
Me.Ctl1.BackColor = 14737632

Case Is = Me.COL3
Me.Ctl1.BackColor = 14737632

Case Is = Me.COL4
Me.Ctl1.BackColor = 14737632

Case Is = Me.COL5
Me.Ctl1.BackColor = 14737632
Case Else
Me.Ctl1.BackColor = 16777215
End Select

Select Case Me.Ctl2
Case Is = Me.COL1
Me.Ctl2.BackColor = 14737632

Case Is = Me.COL2
Me.Ctl2.BackColor = 14737632

Case Is = Me.COL3
Me.Ctl2.BackColor = 14737632

Case Is = Me.COL4
Me.Ctl2.BackColor = 14737632

Case Is = Me.COL5
Me.Ctl2.BackColor = 14737632
Case Else
Me.Ctl2.BackColor = 16777215
End Select

End Sub
When a filter has been applied, I would like the detail background color to
change so they know they are looking at a filtered dataset. I tried the code
below, but all that changes is the filter by form screen BEFORE they apply
the filter. I need it to change color after they apply the filter. What am
I doing wrong? Thanks in advance!

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me.Detail.BackColor = -2147483633
End Sub

Private Sub Form_Filter(Cancel As Integer, FilterType As Integer)
Me.Detail.BackColor = 255
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top