ALTERNATE COLOUR CHANGE CONTINUOUS FORMS - EXPLAINED HERE

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
---------------
 
A

Allen Browne

Richard, thanks for posting your approach.
It's satisfying when you find a solution that works.
It's even more satisifying if others can use it as well.

The other alternative might be to update to Access 2007.
In the new version, you just set the AlternateBackColor property of the
Detail section.
 
R

Richard Smith

WHAT!!!

I am using Access 2007!!

Can you explain how to do this please Allen?

ARGH!!!

Allen Browne said:
Richard, thanks for posting your approach.
It's satisfying when you find a solution that works.
It's even more satisifying if others can use it as well.

The other alternative might be to update to Access 2007.
In the new version, you just set the AlternateBackColor property of the
Detail section.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Richard Smith said:
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
 
D

Douglas J. Steele

http://office.microsoft.com/en-ca/access/HA102190041033.aspx#bm2


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Richard Smith said:
WHAT!!!

I am using Access 2007!!

Can you explain how to do this please Allen?

ARGH!!!

Allen Browne said:
Richard, thanks for posting your approach.
It's satisfying when you find a solution that works.
It's even more satisifying if others can use it as well.

The other alternative might be to update to Access 2007.
In the new version, you just set the AlternateBackColor property of the
Detail section.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Richard Smith said:
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
 
A

Allen Browne

Not too difficult:

1. Open form in design view.

2. Select Detail section.

3. Open Properties sheet.

4. Set AlternateBackColor property.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Richard Smith said:
WHAT!!!

I am using Access 2007!!

Can you explain how to do this please Allen?

ARGH!!!

Allen Browne said:
Richard, thanks for posting your approach.
It's satisfying when you find a solution that works.
It's even more satisifying if others can use it as well.

The other alternative might be to update to Access 2007.
In the new version, you just set the AlternateBackColor property of the
Detail section.

Richard Smith said:
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
---------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top