After update or onExit.

J

Joe M

I would like to create a [Colour] field, that upon exit the text in it will
change to the colour specified in it.
Meaning if the user type Blue in the Colour field, the word blue will be
show in colour blue. And if the value is Red, the word Red will be show in
Red in the [Colour] field.
Should I use Afterupdate or OnExit on the form textbox for it, which is
better?
What's the best way to do this, thanks.
I have used, and how come it's not working???

Colour.OnExit
If Colour="Red"
Colour.forecolor= Red
end if
 
M

Marshall Barton

Joe said:
I would like to create a [Colour] field, that upon exit the text in it will
change to the colour specified in it.
Meaning if the user type Blue in the Colour field, the word blue will be
show in colour blue. And if the value is Red, the word Red will be show in
Red in the [Colour] field.
Should I use Afterupdate or OnExit on the form textbox for it, which is
better?
What's the best way to do this, thanks.
I have used, and how come it's not working???

Colour.OnExit
If Colour="Red"
Colour.forecolor= Red
end if


Colors are not specified by their English name. There are a
few VBA builtin constants for common color names that you
could use:

Colour.ForeColor = vbRed

but the various shades of all the colors can only be
specified by using the RGB function.

Colour.ForeColor = RGB(255,0,0) 'bright red
Colour.ForeColor = RGB(128,0,0) 'dark red
Colour.ForeColor = RGB(255,192,192) 'pink
 
J

Joe M

Thanks Marshall,
I just did:
Colour.OnExit
If Colour="Red"
Colour.forecolor=vbRed
end if

It worked, but only appears RED on the form. It wouldn't insert the value
RED as colour RED into the table. Why?? How do I insert value RED into the
Table as colour red????Thanks.


Marshall Barton said:
Joe said:
I would like to create a [Colour] field, that upon exit the text in it will
change to the colour specified in it.
Meaning if the user type Blue in the Colour field, the word blue will be
show in colour blue. And if the value is Red, the word Red will be show in
Red in the [Colour] field.
Should I use Afterupdate or OnExit on the form textbox for it, which is
better?
What's the best way to do this, thanks.
I have used, and how come it's not working???

Colour.OnExit
If Colour="Red"
Colour.forecolor= Red
end if


Colors are not specified by their English name. There are a
few VBA builtin constants for common color names that you
could use:

Colour.ForeColor = vbRed

but the various shades of all the colors can only be
specified by using the RGB function.

Colour.ForeColor = RGB(255,0,0) 'bright red
Colour.ForeColor = RGB(128,0,0) 'dark red
Colour.ForeColor = RGB(255,192,192) 'pink
 
M

Marshall Barton

Joe said:
Thanks Marshall,
I just did:
Colour.OnExit
If Colour="Red"
Colour.forecolor=vbRed
end if

It worked, but only appears RED on the form. It wouldn't insert the value
RED as colour RED into the table. Why?? How do I insert value RED into the
Table as colour red????Thanks.

You want the string "RED" saved in a table when you type
"RED" in to the text box? If so, the form needs to be bound
to the table and the text box should be bound to the color
field in the table.

Excuse me, but that is so fundamental that I suspect that
I've misunderstood your question. Maybe I could be more
helpful if you explained things in more detail??
--
Marsh
MVP [MS Access]


Joe said:
I would like to create a [Colour] field, that upon exit the text in it will
change to the colour specified in it.
Meaning if the user type Blue in the Colour field, the word blue will be
show in colour blue. And if the value is Red, the word Red will be show in
Red in the [Colour] field.
Should I use Afterupdate or OnExit on the form textbox for it, which is
better?
What's the best way to do this, thanks.
I have used, and how come it's not working???

Colour.OnExit
If Colour="Red"
Colour.forecolor= Red
end if

"Marshall Barton" wrote
Colors are not specified by their English name. There are a
few VBA builtin constants for common color names that you
could use:

Colour.ForeColor = vbRed

but the various shades of all the colors can only be
specified by using the RGB function.

Colour.ForeColor = RGB(255,0,0) 'bright red
Colour.ForeColor = RGB(128,0,0) 'dark red
Colour.ForeColor = RGB(255,192,192) 'pink
 

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