Restoring default control properties

  • Thread starter John Harrington
  • Start date
J

John Harrington

I’ve created a subroutine that looks like this:

Private Sub GrayMeOut(ComponentName As String)
Me.Controls(ComponentName).ForeColor = &HD8D8D8
End Sub

If a text box on my form reads “foo”, I pass the name of another
control to this function, and that control is grayed out. I test for
this in Current.

The problem is, if I advance the form to the next record, the control
will still be grayed out, even if the text box reads something other
than foo (i.e., even if my condition is not met).

So what I want is a method that restores the default properties to the
controls on my form *before* I test to see if my condition is met.

I just need the name of this method and the event I should put it in.
It doesn’t seem to be Me.Form.Refresh. I tried that in the Load
event, and it doesn’t seem to work. Or maybe I have the wrong
event?

Many thanks in advance,
John
 
A

Arvin Meyer [MVP]

You will need to use the form's Current event to return the color for the
next record.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


I’ve created a subroutine that looks like this:

Private Sub GrayMeOut(ComponentName As String)
Me.Controls(ComponentName).ForeColor = &HD8D8D8
End Sub

If a text box on my form reads “foo”, I pass the name of another
control to this function, and that control is grayed out. I test for
this in Current.

The problem is, if I advance the form to the next record, the control
will still be grayed out, even if the text box reads something other
than foo (i.e., even if my condition is not met).

So what I want is a method that restores the default properties to the
controls on my form *before* I test to see if my condition is met.

I just need the name of this method and the event I should put it in.
It doesn’t seem to be Me.Form.Refresh. I tried that in the Load
event, and it doesn’t seem to work. Or maybe I have the wrong
event?

Many thanks in advance,
John
 

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