By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

Color change in ActiveControl

P: n/a
I have a form with 3 related fields. If data is entered into 1 field, the
other 2 related fields are updated automatically. I would like to indicate
on the form into which field the data was initially entered by a) changing
the color of the text or b) by changing the color of the background. Have
tried using Screen.ActiveCell.Backcolor = xxx upon entering the cell but
have not had any luck. Would appreciate help.

Chuck
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
MLH
I use this for changing color of a control OnGotFocus...
=Change2Green("Forms![frmCustEntryfrmVehicleEntryForm]![OwnerID]
OnGotFocus event procedure")

I use this for changing color of a control OnLostFocus...
=Change2Gray("Forms![frmVehicleEntryForm]![OwnerID] OnLostFocus event
procedure")

Maybe you can modif them somehow to get what you want. Here's a basic
color changer procedure...

Function Change2DarkGreen()
Dim MyControl As Control
Set MyControl = Screen.ActiveControl
MyControl.BackColor = 32768

'This function can be called from most anywhere. However, when
first opening a form
'and going to the very first control - if called, this code
pukes. You have to handle
'that a different way: Me![ControlName].BackColor=65280 works
just fine when entered
'as code-behind-form on the OnGotFocus property for the
control. This is ONLY for the
'very first control on a form. All subsequent controls can
call this function without
'any problem whatsoever!

End Function

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
On Sat, 18 Jun 2005 09:46:18 -0700, "Chuck" <ch*****@comcast.net>
wrote:
I have a form with 3 related fields. If data is entered into 1 field, the
other 2 related fields are updated automatically. I would like to indicate
on the form into which field the data was initially entered by a) changing
the color of the text or b) by changing the color of the background. Have
tried using Screen.ActiveCell.Backcolor = xxx upon entering the cell but
have not had any luck. Would appreciate help.

Chuck


Nov 13 '05 #2

P: n/a
MLH
Sorry, Chuck...
Better use this format for the color changer procedure. I gave
you an earlier one that I don't use much any more.

Function Change2Gray(CallingProcedure As String)
On Error GoTo Change2Gray_Err

Dim MyControl As Control
Set MyControl = Screen.ActiveControl
MyControl.BackColor = 12632256

Change2Gray_Exit:
Exit Function

Change2Gray_Err:
Dim r As String, Z As String, Message3 As String
r = "The following unexpected error occurred in Function
Change2Gray() when called from " & CallingProcedure & ":"
Z = CRLF & CRLF & Str$(Err) & ": " & Quote & Error$ & Quote
Message3 = r & Z
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume Change2Gray_Exit

End Function

Nov 13 '05 #3

P: n/a

MLH,

Reallu appreciate your help. Tried to use your input,but no success.
Wanted to attach the trial mdb, only 4 fields, 160K unzipped (14K
zipped) but don't know how. If you can either tell me how, or send your
email address I'll get it to you asap.

Chuck

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #4

P: n/a
MHL,

Found out what the problem was. The back color only shows in Form View.
I have been in Datasheet View. I wanted to see, in Datasheet View, the
initial input field highlighted, somehow, in every initial input field
for all records. Is that possible?

Chuck

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #5

P: n/a
MLH
You've got me there. I have never tried datasheet
view. Don't know why not. Just never thought I
needed it for anything.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Sat, 18 Jun 2005 23:15:00 GMT, Chuck Goldstein <ch*****@acm.org>
wrote:
MHL,

Found out what the problem was. The back color only shows in Form View.
I have been in Datasheet View. I wanted to see, in Datasheet View, the
initial input field highlighted, somehow, in every initial input field
for all records. Is that possible?

Chuck

*** Sent via Developersdex http://www.developersdex.com ***


Nov 13 '05 #6

P: n/a

Thanks, MLH. I appreciate your responses, nonetheless. At least I now
know how to do this of cells in Form Mode. If I ever find out how to do
it in Display ode, I'll let you know.

Chuck
*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #7

P: n/a
MLH
Alright.
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.