K
Kel
Hi,
I have reposted this query (originally on the modulesdaovbs newsgroup) as I
still can't find a suitable solution -
despite some helpful responses. I would really appreciate any suggestions:
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. I am using the solution which uses
conditional formatting on a dummy textbox
which covers the background of the section (using the
ClsConditionalFormatting class - if anyone is familiar with the code). 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.
Currently the code I am using checks if this is a New Record or if this
control's value is Null and returns False if either conditions are true -
this then stops the conditional formatting for the current record - so I was
recomended to comment out this If/End if block and this would allow
conditional formatting for the new record.
However this only works if the new record is the first record in the
continuous view and I have discovered this is for the following reason (if
you aren't familiar with the code from Lebans.com then this may not make any
sense to you!):
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 suggested (removing the If/End If block) 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.
Does anyone have any ideas? - I would be indebted if you do
Kel
I have reposted this query (originally on the modulesdaovbs newsgroup) as I
still can't find a suitable solution -
despite some helpful responses. I would really appreciate any suggestions:
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. I am using the solution which uses
conditional formatting on a dummy textbox
which covers the background of the section (using the
ClsConditionalFormatting class - if anyone is familiar with the code). 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.
Currently the code I am using checks if this is a New Record or if this
control's value is Null and returns False if either conditions are true -
this then stops the conditional formatting for the current record - so I was
recomended to comment out this If/End if block and this would allow
conditional formatting for the new record.
However this only works if the new record is the first record in the
continuous view and I have discovered this is for the following reason (if
you aren't familiar with the code from Lebans.com then this may not make any
sense to you!):
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 suggested (removing the If/End If block) 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.
Does anyone have any ideas? - I would be indebted if you do
Kel