Changing a form color depending on a variable value

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Hello

I wish to change the color of a form depending on the value of a variable.
If the var "SigOther" [boolean] is true then I want the form to be pink else
a light blue.

Thanks a lot
 
Tony

Where is that "variable"? Is it part of a procedure, or are you referring
to a control on the form?

If a control on a form, one approach might be to use the AfterUpdate event
of that control and set the form's background color to whatever...

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Sorry about that.
It is a field on a form taken from a table

Jeff Boyce said:
Tony

Where is that "variable"? Is it part of a procedure, or are you referring
to a control on the form?

If a control on a form, one approach might be to use the AfterUpdate event
of that control and set the form's background color to whatever...

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned
in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

Tony said:
Hello

I wish to change the color of a form depending on the value of a
variable.
If the var "SigOther" [boolean] is true then I want the form to be pink
else a light blue.

Thanks a lot
 
you can change the back ground color quite easily. see
http://www.devhut.net/index.php?lang=en&pid=0000000011#chgBkgrndColor

To determine the color to use you can use the color utility I created, which
can be found at http://www.devhut.net/index.php?lang=en&pid=0000000007#colors

But basically you'd use the afterupdate event and the current event of the
form and do something like the following for each of them

If SigOther = True then
Me.Section(acDetail).BackColor = 16757247 'Pink
Else
Me.Section(acDetail).BackColor = -958615391 'Light Blue
End if

You need to use the after update for the SigOther control to adjust when the
user makes changes, but also need to use the oncurrent to adjust between
records when they get loaded.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
It works a treat.
I live in Darwin so I'll go to bed and sleep well.

Thanks a lot
Daniel Pineault said:
you can change the back ground color quite easily. see
http://www.devhut.net/index.php?lang=en&pid=0000000011#chgBkgrndColor

To determine the color to use you can use the color utility I created,
which
can be found at
http://www.devhut.net/index.php?lang=en&pid=0000000007#colors

But basically you'd use the afterupdate event and the current event of the
form and do something like the following for each of them

If SigOther = True then
Me.Section(acDetail).BackColor = 16757247 'Pink
Else
Me.Section(acDetail).BackColor = -958615391 'Light Blue
End if

You need to use the after update for the SigOther control to adjust when
the
user makes changes, but also need to use the oncurrent to adjust between
records when they get loaded.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



Tony said:
Hello

I wish to change the color of a form depending on the value of a
variable.
If the var "SigOther" [boolean] is true then I want the form to be pink
else
a light blue.

Thanks a lot
 
Back
Top