Conditional Formatting - Continuous Forms (Lebans.com)

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Can anyone help me understand how to use the conditional
formatting code that lebans.com has for a continuous form
into my own applications?

I tried to copy the code, by exporting the cls and mod
and, by actually copy/paste the code into my own app.
Everytime I do that, and try to run my application, I get
a "File Not Found" error. I am not a programmer and I
can't figure out how to make this work. I've tried to
decipher the code, but no success.

Please help.
 
Joshua,

The link you provided in your eariler response does not
work. I tried to search through the library and could not
locate it. Can you tell me specifically what 'tree' you
found this in?
 
Never mind...I found it...however, this does not solve my
dilemma. If you look at what www.lemans.com provides, the
formatting applies when a control 'has focus', there is no
user entry required. It highlights the entire row in a
continuous form, but only the current row, not all rows.
What this article describes is when the user types in a
specific value which is not what I was looking for.

Basically I want the form to highlight all controls in a
single row where any control has focus so the user knows
which record they are making a change to.
 
Frank,

Using the OnCurrent Event of the form, you can set a yes/no field to true
for the current record then use this field in conditional formatting.

HTH,
Josh
 
What exact problems are you having? If you look at the code behind the
sample form, "CustomerInContinuousViewCurrentRow", there are only 6
lines of code yfor you add to your own form.
Import all of the class and code modules from my sample MDB into your
own.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
One of the benefits of CF is that you no longer have to add a column to
your data tables just to achive the desired formatting effect.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Stephen,

How can you highlight the current row using Conditional Formatting without
adding a column?

TIA,
Josh
 
Call a custom function to be evaluated by CF. Here's a sample function:

' This is the function called by our Expression evaluated
' by the FormatConditions object.
' This current version will only work when
' the ControlSource for the control contains a FIELD Name.

Public Function fCurrentRow(ctl As Control) As Boolean
' Find the record that matches the value passed to this function.
' If return TRUE then the Current Row will be highlighted

On Error Resume Next

Dim rs As Object
Dim frm As Form


' Need to enhance this to allow for SubForms
Set frm = ctl.Parent


' If we are on a new record or field = NULL then exit
If frm.NewRecord = True Or IsNull(ctl.Value) Then
fCurrentRow = False
Set frm = Nothing
Exit Function
End If

' Get a reference to a copy of the Form's recordset
Set rs = frm.RecordsetClone


' Move to the desired row
rs.FindFirst ctl.ControlSource & " = " & Nz(ctl.Value, "")
' See if we have a match
If rs.AbsolutePosition + 1 = frm.CurrentRecord Then
' If we match then return True to the
' Conditional Formatting Expression. This signifies
' that we want the background TextBox control
' to be rendered as per our FormatCondition object properties.
fCurrentRow = True
'Debug.Print "Match:"
Else
' Return False, do nothing.
fCurrentRow = False
End If

' Cleanup
Set rs = Nothing
Set frm = Nothing
End Function


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
After importing the class and code modules, I open the form
in design view so I can add to the OnCurrent, On Load and
OnUnload events. As soon as I click to add that code in
there, I get an error message: "Error Accessing File.
Network connection may have been lost." (FYI, i'm
accessing this file directly from my PC, not a network).
 
This has nothing to do with my code. It is a known bug of Access 2K. YOu
MUST apply at least the first Service Release(SR1). THe MDB is
corrupted. Try importing everthing you can into a new blank MDB.
Take a moment to read:
ACC2000: Error Message: Error Accessing File. Network Connection May
Have Been Lost
http://support.microsoft.com/default.aspx?scid=kb;en-us;304548&Product=a
cc2000
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Ok...I got the fix in just fine using the Knowledge Base
article! Thank you for that.

Now that I can access the code just fine, everything 'seems
to be working', but it is not highligting. I changed the
the KeyFieldControl = Me.'yourfield' to my field name and
all other instances of it throughout the code. It just
doesn't want to hightlight.

What am I doing wrong??
 
The only place you would change the reference to the TextBox control's
name is in your Form's Load event after you instantiate the class.
Remember as the instructions state you must set the class's
KeyFieldCOntrol to that of a TEXTBOX control that is bound to field
containing unique values. In the sample code below the TextBox control's
name is txtCustomerID. Substitute the NAME of the TextBox control on
your form that is bound to a filed containing unique values.

If you have changed my code anywhere else then delete all of my code
class modules and import them again from my sample MDB.

Private Sub Form_Load()
' startup our class
Set CF = New clsConditionalFormattingDataSheetView
' 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.KeyFieldControl = Me.txtcustomerID

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

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Ok, i'm just not getting this to work right and it's 11PM...i've about had
it for the night...

(The textbox HAS to have unique values, such as a customerID as you have it
in your form, right?, does the textbox have to be visible on the form, or
can it be hidden from the users if I don't need them to see that field?)

I'll pick this up on Monday.

Thanks for your paitence with me, and your help!
 
The TextBox control does not have to be visible and yes it must be bound
to a field containing unique values.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top