|
|
A2K or Higher Only! New Feb 08,2002. Added support for Datasheet view and SubForms. A2KConditionalFormatting.zip is a sample MDB demonstrating how to programmatically setup Conditional Formatting to simulate: 1) Highlighting of the Current Row for a Form in Continuous or Datasheet View 2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet View Version 2.7 Added sample demonstrating how to achieve a background Hover/Highlighting of rows for a form in Continuous view. Version 2.3 Added sample demonstrating how to achieve pseudo enable/disable of an unbound control on a form in Continuous View. Version 1.9 Added sample form to show how to apply conditional formatting to based on a Boolean(Yes/No) field. Verrsion 1.8 Starting to cleanup code and add comments! Version 1.4 First release 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
Author: Van T. Dinh I am helping someone to use the above to highlight the CurrentRecord of a Subform in ContinuousFormView in his database. I eventually found out that he couldn't get your Class Module "clsConditionalFormattingDataSheetView" to work due to the explicit references to the actual Control "txtcustomerid" rather than the "mKeyControl" TextBox object in the Class Module. Here is the statement from your Class Module: .... If mShowHighlightingAlternate = False Then Set objFrc = ctl.FormatConditions.Add(acExpression, _ , "fCurrentRow([txtcustomerid])") Else Set objFrc = ctl.FormatConditions.Add(acExpression, _ , "fAlternateRow([txtcustomerid])") End If ... I have changed the above statements to the following: ... If mShowHighlightingAlternate = False Then Set objFrc = ctl.FormatConditions.ADD(acExpression, _ , "fCurrentRow([" & mKeyControl.Name & "])") Else Set objFrc = ctl.FormatConditions.ADD(acExpression, _ , "fAlternateRow([" & mKeyControl.Name & "])") End If ... so that it works in general which seems to work fine in the mdb I am working on. Cheers Van T. Dinh |
|
|