Changing color of a textbox in a subform

D

DontKnow

Hi Guys,

I am trying to change the color of a textbox in a subform, but so far with
not much luck.
The code that I am currently using is:

Me.textboxname.backcolor = 255 'To change the color of the textbox to red
Me.textboxname. value = "changeme"

The 2nd line of cocde works but unfortunately I cannot get the background
color to change. I don't know what I am doing wrong.

I have also tried:
Me.textboxname.backcolor = rgb(255,0,0)
and still no luck!!

I am using the textbox in a subform and datasheet view ( i believe that you
can change the backcolor of a textbox in a subform and datasheet view during
runtime??)

Any suggestions??

Cheers,
 
M

MikeJohnB

Hi, if you simply want Red one way is
Me.TextboxName.BackColor = vbRed

I am not sure why 255 is not working for you, will try it.

I hope this has answered your question?
 
M

MikeJohnB

I have confirmed that Me.txtBoxName.BackColor = 255 works. So where are
you placing the code in which control and on which event?

Regards
 
J

John W. Vinson

I have also tried:
Me.textboxname.backcolor = rgb(255,0,0)
and still no luck!!

I am using the textbox in a subform and datasheet view ( i believe that you
can change the backcolor of a textbox in a subform and datasheet view during
runtime??)

Not in a datasheet to my knowledge - you can do so in a Continuous Form.

Another option (which I believe works with datasheets too) is to use Format...
Conditional Formatting from the menu.
 
D

DontKnow

Hi Guys,

yes I am trying to update the textbox color in a datasheet view!!

Hi John,

How do you use "format" to change the color,

any advice would certainly help!!

Cheers,
 
J

John W. Vinson

Hi Guys,

yes I am trying to update the textbox color in a datasheet view!!

Hi John,

How do you use "format" to change the color,

any advice would certainly help!!

Open the Form in design view. Select the textbox bound to the field that you
want to change color. On the Menu choose "Format", and then select
"Conditional Formatting".

Choose the color you want using the color tool.
 
D

DontKnow

I just checked and conditional formatting does not work for the datasheet
view and subform for a text box!!

Thnaks for your help anyway!!

Cheers
 
J

John W. Vinson

I just checked and conditional formatting does not work for the datasheet
view and subform for a text box!!

It does on my PC (A2003 SP3); I tried a second time to be sure. Just what did
you do???
 
R

Ron2006

That is not accurate. Conditional formating works fine on datasheet
views.

I have and do use it extensively.

If you want one certain field to be red all the time then change the
condition on the conditional format screen to use an expression and
simply type True in the expression. and then choose the
formating that you want.

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