dbTalk Databases Forums  

Dynamically setting the Backcolor property

comp.databases.ms-access comp.databases.ms-access


Discuss Dynamically setting the Backcolor property in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JohnP
 
Posts: n/a

Default Dynamically setting the Backcolor property - 01-27-2011 , 08:16 AM






I want to set the Backcolor property of a text box automatically. The
value of the Backcolor is stored in another text box in the same
record.
Thanks,
John

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 08:30 AM






On 27/01/2011 14:16:04, JohnP wrote:
Quote:
I want to set the Backcolor property of a text box automatically. The
value of the Backcolor is stored in another text box in the same
record.
Thanks,
John

PrettyTextBox.BackColor = Nz(TextBoxWithColourDefined)

Phil

Reply With Quote
  #3  
Old   
JohnP
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 08:59 AM



Phil, I had tried that, with no success.

Assume a Tabular subform containing a bound text box called
"cbolngPatientID" that needs to have its backcolor set automatically.
The backcolor number is held in textbox "lngBackcolor". Both textboxes
are in the same record. I created textbox "lngBackcolor" for ease of
use and it does a DLookup in another textbox "lngServiceID" to
retrieve the backcolor number.
John

Reply With Quote
  #4  
Old   
Phil
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 11:34 AM



On 27/01/2011 14:59:25, JohnP wrote:
Quote:
Phil, I had tried that, with no success.

Assume a Tabular subform containing a bound text box called
"cbolngPatientID" that needs to have its backcolor set automatically.
The backcolor number is held in textbox "lngBackcolor". Both textboxes
are in the same record. I created textbox "lngBackcolor" for ease of
use and it does a DLookup in another textbox "lngServiceID" to
retrieve the backcolor number.
John

Ah. You didn't say it was a continuous form.
Much more difficult. I have done it, but can't find it at the moment.
In the meantime, have a look at http://www.lebans.com/formatbycriteria.htm.
Phil

Reply With Quote
  #5  
Old   
JohnP
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 12:50 PM



Unfortunately it is a continuous form. I had a look at the code you
referred to. As you know, it paints the entire row and not a selected
text box. Any suggestions would be greatly appreciated. This is a
prime example of something that appears to be simple to implement but
it is not.
Thanks for your help,
John

Reply With Quote
  #6  
Old   
Bob Quintal
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 05:09 PM



JohnP <john (AT) kosmosbusiness (DOT) com> wrote in
news:df95098d-b44c-4417-a8d2-4da913b6efe4 (AT) g1g2000prb (DOT) googlegroups.com
:

Quote:
Unfortunately it is a continuous form. I had a look at the code
you referred to. As you know, it paints the entire row and not a
selected text box. Any suggestions would be greatly appreciated.
This is a prime example of something that appears to be simple to
implement but it is not.
Thanks for your help,
John
What you must do is layer several textboxes.
the topmost textbox contains your cbolngPatientID
and has a transparent background.

For each color (hopefully only a few colors),
you add a textbox behind the existing ones, which gets its contents
from a field calculated in the query behind the form, the
calculation is similar to
string(10,chr(IIF(WantedColorRed=true,219,32)) set the font to
terminal, font size to fill the box and you make the background is
transparent and the foreground color is Red. The next tectbox would
be blue, etc.

in the Terminal font, Chr(219) is a solid box, 32 is space, so
depending on the caLculation is true or false the foreground gets
filled with the boxes or spaces. Since the box is behind the box
with the text,it looks like the background of the front textbox
changes color.


--
Bob Q.
PA is y I've altered my address.

Reply With Quote
  #7  
Old   
Phil
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 05:52 PM



On 27/01/2011 18:50:24, JohnP wrote:
Quote:
Unfortunately it is a continuous form. I had a look at the code you
referred to. As you know, it paints the entire row and not a selected
text box. Any suggestions would be greatly appreciated. This is a
prime example of something that appears to be simple to implement
it is not.
Thanks for your help,
John

Sorry if not much help, but if you select the "Only the Control" option in
that sample DB, thats pretty well exactly what it does. Phil

Reply With Quote
  #8  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 07:11 PM



Bob Quintal wrote:

Quote:
JohnP <john (AT) kosmosbusiness (DOT) com> wrote
:
Unfortunately it is a continuous form. I had a look at the code
you referred to. As you know, it paints the entire row and not a
selected text box. Any suggestions would be greatly appreciated.
This is a prime example of something that appears to be simple to
implement but it is not.
Thanks for your help,
John

What you must do is layer several textboxes.
the topmost textbox contains your cbolngPatientID
and has a transparent background.

For each color (hopefully only a few colors),
you add a textbox behind the existing ones, which gets its contents
from a field calculated in the query behind the form, the
calculation is similar to
string(10,chr(IIF(WantedColorRed=true,219,32)) set the font to
terminal, font size to fill the box and you make the background is
transparent and the foreground color is Red. The next tectbox would
be blue, etc.

in the Terminal font, Chr(219) is a solid box, 32 is space, so
depending on the caLculation is true or false the foreground gets
filled with the boxes or spaces. Since the box is behind the box
with the text,it looks like the background of the front textbox
changes color.

Be careful with the Terminal font. It is not a full solid
box in all versions of the font distributed with various
verions of Windows (e.g. may lack a top or bottom row of
pixels). You may be interested in this article:
http://www.mvps.org/access/forms/frm0055.htm

--
Marsh

Reply With Quote
  #9  
Old   
Access Developer
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-27-2011 , 08:51 PM



"JohnP" <john (AT) kosmosbusiness (DOT) com> wrote

Quote:
I want to set the Backcolor property of a
text box automatically. The value of the
Backcolor is stored in another text box
in the same record.
I have the advantage of having seen some responses and knowing that you are
talking about a continuous form. Since Access 2000, you can use Conditional
Formatting. There's a discussion of it at:

http://office.microsoft.com/en-us/ac...01044851.aspxI don't recall it being sufficiently flexible to pick up the color fromanother field in the same record, though. Larry

Reply With Quote
  #10  
Old   
JohnP
 
Posts: n/a

Default Re: Dynamically setting the Backcolor property - 01-28-2011 , 01:19 AM



Very interesting replies, thanks to all. Regarding Bob's suggestion, I
would prefer not to add the extra text box and there may be a problem
with the Terminal font as Phil mentioned. With the Lebans code we need
to basically create a Bitmap to match (exactly) the dimensions of the
Detail section of the form and then manipulate this bitmap.

I thought about using Conditional formatting but did not investigate
further. The link that so kindly Larry sent over, does not appear to
work.

Do you know whether Conditional formatting + VBA would do the trick? I
will investigate anyway.

John

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.