Problems with Lebans CF Modules

Pisteuo

Registered User.
Local time
Today, 13:54
Joined
Jul 12, 2009
Messages
72
I am working in 2003 and would like to highlight current rows in a continuous form. I found Lebans sample MDB at www.lebans.com/conditionalformatting.htm

I pasted and reviewed the included modules and form code.

On my form the background textbox is being activated and hovering above all the records, both current and non-current. The only visible control is the On Current primary key.

This release note is included on the website:

#Release Notes:
Private Sub Form_Load()
Dim objFrc As FormatCondition

' Remove any existing format conditions.
Me.txtBackGround.FormatConditions.Delete

' Create a format object and add it to the FormatConditions collection.
' We have to pass to pass a value to the function otherwise
' Access will only execute the function once.
' Also due to a bug we must programmatically setup the
' Conditional Formatting here. Otherwise if you were to setup
' CF via the GUI the state of the Disabled property
' is not respected. This will allow our Background TextBox control
' to receive the focus and be activated - something we don't want!!

Set objFrc = Me.txtBackGround.FormatConditions.Add(acExpression, _
, "Hover([txtFormat],[RowNumber])")

' Setup our props
With Me.txtBackGround.FormatConditions(0)
.BackColor = vbRed
.Enabled = False
End With
Set objFrc = Nothing
End Sub

The original form code reads like this:

Option Compare Database
' Declare an instance of our class
Private CF As ClsConditionalFormatting

Private Sub Form_Current()

' Call our redraw function.
' We have to do this here because of a bug using
' Withevents to sink a Form's events from a Class module.

CF.Redraw
End Sub

Private Sub Form_Load()

' startup our class
Set CF = New ClsConditionalFormatting

' You must set a reference to a TextBox control
' that you have placed anywhere in the Detail section.
' Don't worry about the control's size or placement.
' The class will position, size and set it's properties as required.
CF.BGTextBox = Me.txtBackGround

' Set the desired Highlight Color
CF.HighlightColor = CLng(vbRed)
End Sub

Private Sub Form_Unload(Cancel As Integer)
' Release the reference to our class.
Set CF = Nothing
End Sub

' Control Highlighting for Current Row
Private Sub cmdOff_Click()
CF.ShowHighlighting = False
End Sub

Private Sub cmdOn_Click()
CF.ShowHighlighting = True
End Sub

What should I do about the original Load Event code? Leave it or take it out? If I take it out only the primary key is highlighted, and highlighted for all records, not just current. Also the Current Event's "CF.Redraw" will not work since the new Load Event code does not reference the CF variable.

Or maybe soembody knows an easier way to highlight rows in 2003?
Thank you.
 

Users who are viewing this thread

Back
Top Bottom