Highlight New Record

  • Thread starter Thread starter Kel
  • Start date Start date
K

Kel

Hi,

I wonder if anyone can help - I am currently developing database in which I
have used the method found on Lebans.com for highlighting the background of
the current record in a continuous form. This works well, however the one
thing it does not do is to highlight the record if it is a new record - this
is pretty important to the functionality (ie there's not much point in me
highlighting the current record if it can't highlight a new one!) and I have
spent a while trying to figure out a way round it. Many methods have come
close but fallen short!

Anyone have any ideas - or is it a lost cause?!
 
Which of the two solutions for highlighting the current record are you
using from my site?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
I am using the solution which uses conditional formatting on a dummy textbox
which covers the background of the section (using the
ClsConditionalFormatting class). - Very useful code by the way - Thanks :)
 
YOu just have to change a couple of lines of code.
Go into the code module named modCOndiitonalFormatting
Find the fCurrentRow function.

Currently the code:
checks if this is a New Record or if this control's value is Null
if either of the above conditions is true then it Returns FALSE which
tells CF NOT to use CF on this control.

So just comment out the entire If /End If block and you will get the
functionality you want.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thanks for the recommendation, but that was one of the first things I tried
and it only works if the new record is the first record in the continuous
view. This is because when you select a new record, the absoluteposition is
returned as 0, regardless of which position the new record is in, so
therefore if the new record is the fourth record to be created, then the
piece of code....

If rs.AbsolutePosition + 1 = frm.CurrentRecord Then
fCurrentRow = True
Else
fCurrentRow = False
End If

....which decides whether the row should be formatted or not will return
false because frm.currentrecord = 4, but the absoluteposition is still 0.

Using the method you suggested also causes a problem when it is the first
record you select. AbsolutePosition for both the first record and the
'placeholder' for a new record is returned as 0, therefore if you select the
first record, both the first record and the new record placeholder both
evaluate to TRUE in the above code and are therefore both highlighted.

The nearest I have got is to create a variable artificialAbsPosn as long,
force a value onto it if it is a new record and use that for comparison:
e.g.
If IsNull(ctl.Value) Then
rs.MoveLast
artificialAbsPosn = rs.AbsolutePosition + 1 'assume next record
after last record is new record
Else
artificialAbsPosn = rs.AbsolutePosition
End If
' See if we have a match
If artificialAbsPosn + 1 = frm.CurrentRecord Then
fCurrentRow = True
Else
fCurrentRow = False
End If

This works fine until you start to enter data into the new record, at which
point the next new record 'placeholder' is created and this is highlighted
instead of the current new record.

I am also unsure about assuming that the new record will have a null value
(as you can't use frm.newrecord to evaluate as this would evaluate true for
all records looped through) and I am also unsure about assuming the next
record after last record is new record.

Any more ideas?
 
Back
Top