R
Richard Smith
It seems as though everyone that has a continuous form/subform wants to
alternate the colour of the records, to make it look pretty or to make the
results easier to read.
Lebans website has some great techniques, but none that were easy to follow
and easy to implement (IMO), so I thought I would take my extremely limited
knowledge and tackle the problem myself and I have been successful - YAY me!!!
Here's how I did it - not the cleanest way (I know) but it works.
In your subform put an unbound control anywhere and make it 0cm high and 0cm
wide - I called it LineNum.
Sets it's control to
=GetLineNumber([Formname],"tablename",[autonumberfield])
This control then returns the number of the record that is being displayed
Now you have that, whenever you run the subform, you should see -
1
2
3
4
5
Next, I changed all the fields in my Subform to have a transparent
background and put another unbound control behind it, stretch it to the full
width of the subform, next sets it's control to =IIf([LineNum] Mod
2=0,"Even","Odd")
This control then displays whether the record is Odd or Even
Using Conditional Formatting, I was then able to change the colour of this
if it is not equal to "even".
Voila.............or so I thought
I next found that if a user selects a record, that record would disappear
(hidden), so I stuck a Label with a . (fullstop), a transparent background
with no border and placed that straight over the top of all my subform fields
- as I don't want the user to be able to edit the records from this form.
I then created another control called txtfocus and made it 0cm high and 0cm
wide, with a bit of code to the afterupdate control of the Subform I just
then set the focus to the txtfocus.
Works for me!!
Well, hopefully this helps anyone in the same boat I was in, I would be
interested to hear anyone that finds this useful or even anyone that knows an
easier way of achieving the same result.
Cheers
Richard
---------------
alternate the colour of the records, to make it look pretty or to make the
results easier to read.
Lebans website has some great techniques, but none that were easy to follow
and easy to implement (IMO), so I thought I would take my extremely limited
knowledge and tackle the problem myself and I have been successful - YAY me!!!
Here's how I did it - not the cleanest way (I know) but it works.
In your subform put an unbound control anywhere and make it 0cm high and 0cm
wide - I called it LineNum.
Sets it's control to
=GetLineNumber([Formname],"tablename",[autonumberfield])
This control then returns the number of the record that is being displayed
Now you have that, whenever you run the subform, you should see -
1
2
3
4
5
Next, I changed all the fields in my Subform to have a transparent
background and put another unbound control behind it, stretch it to the full
width of the subform, next sets it's control to =IIf([LineNum] Mod
2=0,"Even","Odd")
This control then displays whether the record is Odd or Even
Using Conditional Formatting, I was then able to change the colour of this
if it is not equal to "even".
Voila.............or so I thought
I next found that if a user selects a record, that record would disappear
(hidden), so I stuck a Label with a . (fullstop), a transparent background
with no border and placed that straight over the top of all my subform fields
- as I don't want the user to be able to edit the records from this form.
I then created another control called txtfocus and made it 0cm high and 0cm
wide, with a bit of code to the afterupdate control of the Subform I just
then set the focus to the txtfocus.
Works for me!!
Well, hopefully this helps anyone in the same boat I was in, I would be
interested to hear anyone that finds this useful or even anyone that knows an
easier way of achieving the same result.
Cheers
Richard
---------------