Changing Backround Color.

  • Thread starter Thread starter Antonio
  • Start date Start date
A

Antonio

I have a form that contains several data fields. For the
field properties the Backround Style + Transparent and the
Backround Color = White. Is there a way to set the fields
so that each time data is entered into the field the
backround color changes from white to a different color?

TIA
Antonio
 
Do you mean, when the user types some characters into a previously-blank
field, its color should instantly change to something else?

TC
 
Note that the color of the background is ignored by ACCESS when the
control's back style is set to Transparent.

You could use an event that the control has to change either of these
properties. For example, if you want to change the style and color when
focus is received by the control and when focus is lost:

Private Sub ControlName_GotFocus()
' change back style to Solid
Me.ControlName.BackStyle = 1
' change back color to white
Me.ControlName.BackColor = 16777215
End Sub

Private Sub ControlName_LostFocus()
' change back style to Transparent
Me.ControlName.BackStyle = 0
' change back color to white
Me.ControlName.BackColor = 16777215
End Sub
 
Yes, exactly.
-----Original Message-----
Do you mean, when the user types some characters into a previously-blank
field, its color should instantly change to something else?

TC





.
 
Ok.

- The Change event of a control, will fire whenever you type a character
into it. So that is the event you need.

- The background color of a control, is changed by setting its BackColor
property to a number. For example, 0=black. 255=red. Or better, use the
RGB() function. For example, RGB(11,22,33) returns a number for the color
defined by Red (11 of 255 maximum), Green (22 of 255 maximum) and Blue (33
of 255 maximum).

So you just need to code a Change event for the control(s) in question, to
change their BackColor properties to a color number as defined above.

I will not try to give you the code, because I don't have Access here to
check. But it should be very simple.

HTH,
TC
 
Back
Top