Field-By-Field Data Driven Colours on Forms... "On Format"?

G

Guest

I'll simplify the scenario - I hope there's a way to solve this.

I have a form which displays an address, and then a sub-form which displays
(as a continuous form) the people who live at that address and their gender.

On the subform, I would like to display the Males in Blue, and the Females
in Red.

On a report, this is easy - just set up some code in the "On Format" event
which states basically "If Gender = M then Colour = Blue, else Colour = Red".
Easy-peasy.

How do I do this on a FORM?

If I use the On Current event (or really any other event I've tried), it
changes the colour for ALL records on the Form. So basically if my top
record is male, EACH record shows up blue, and vice versa (if top is female,
they all show up red).

I'm hoping there's a simple solution for this - I do not want to have to use
a report to display this data...

Thanks in advance...

Greg
 
G

Guest

Thanks Jeff - but I should have been clearer in my original question.

The work that I need to do is much more complex than simply "if Gender is
M", so I need to be able to write some fairly complex code in order to decide
how to format the fields. The simple 'conditional formatting' option from
the 'format' menu is not powerful enough for me - I need to know how to do it
in VBA in order for this to work for me...

(Basically I'm going to be writing some fairly complex matching algorithms
and then displaying the matches in various different colours).

So I'm looking for the "on format" event equivalent for Forms, if it exists...

Thanks in advance...

Greg
 
R

Ron2006

Conditional format gives you 3 formating choices.

If you added code to you query that is supplying the data to create an
extra field that contains a simple final value (up to 3 besides the
default) then you can use the conditional format.

If the form is NOT continuous then you can make the logic as extensive
as you want and put it in the on current event and/or whatever fields
that could change and would control your color choice.

Those are the only choices I can think of.

Ron
 

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