Change background colour (1 Viewer)

MaleNurse325

Registered User.
Local time
Today, 01:21
Joined
Jan 11, 2016
Messages
67
Is it possible to change the background colour on a form as a conditional format?

Two fields. [Normal Position] and [Current Position] the options are 'Open' and 'Closed'

id like to change the background colour of the form if these fields do not match.
Can it be done?

Cheers guys and ladies
:banghead::banghead:
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:21
Joined
Feb 19, 2013
Messages
16,553
not with conditional formatting which only applies to certain types of controls. And you would not have a 'form' backcolor - the colour is set in the section (detail, header, footer etc)

the code would be something like

Code:
if [Normal Position] = [Current Position] then
    me.detail.backcolor=vbGreen
else
    me.detail.backcolor=vbRed
end if
I would put this in a separate function in your form called say 'setFormColor' and then call it on the form current event plus the after update events for the two controls
 

Mark_

Longboard on the internet
Local time
Today, 01:21
Joined
Sep 12, 2017
Messages
2,111
How I would do this is fairly easy. I would add a small sub, say "TCO_Background". In the In the AfterAccept (or BeforeAccept) of each relevant control I would add TCO_Background.

TCO_Background does you check and sets the forms .backcolor as needed.

NOTE: This will need to be done a little differently if you are using a form in continuous mode as those are not as friendly for doing this type of thing.

CJ beat me to it...
 
Last edited:

MaleNurse325

Registered User.
Local time
Today, 01:21
Joined
Jan 11, 2016
Messages
67
Thank you.
its people like you that make people like me look almost competent :)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:21
Joined
Feb 19, 2013
Messages
16,553
I'm sure you are more competent that us in your chosen career;)
 

Users who are viewing this thread

Top Bottom