Enabling a control in a form conditionally

J

jmackerman

Please help! How do I enable a control conditionally from antoher field?
For example, if a Yes/No field is checked Yes, then the next control should
be enabled

How do I do this?
 
A

Arvin Meyer

jmackerman said:
Please help! How do I enable a control conditionally from antoher field?
For example, if a Yes/No field is checked Yes, then the next control should
be enabled

How do I do this?

Add the following to both the after update of the checkbox and current event
of the form:

If Me.chkWhatever = True Then
Me.txtNextControl.Enabled = True
Else
Me.txtNextControl.Enabled = False
End If

substituting your names, of course.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
S

Sergey Poberezovskiy

In your checkBox AfterUpdate event put code similar to the
following:
nextControl.Enabled = thisCheckBox.Value

HTH
 
J

John Vinson

Please help! How do I enable a control conditionally from antoher field?
For example, if a Yes/No field is checked Yes, then the next control should
be enabled

How do I do this?

Just to add to Arvin and Sergei's suggestions, you will want to put
the same code in the form's Current event to enable/disable the
control appropriately when you move from record to record.

John W. Vinson[MVP]
 
S

Sergey Poberezovskiy

That is given that the form is bound..

-----Original Message-----


Just to add to Arvin and Sergei's suggestions, you will want to put
the same code in the form's Current event to enable/disable the
control appropriately when you move from record to record.

John W. Vinson[MVP]
.
 
A

Arvin Meyer

Actually, not. It needs to be in the Current event regardless of whether the
form is bound or not. Since well over 90% of Access MDB forms are bound,
it's a pretty safe bet to assume that this one is too. In any case, bound or
not, the Current event fires with each record loaded and would be required
unless the form loaded only a single record before it was closed. Even in
that case, one would use the Open or Load event if the Current event wasn't
used. If you read my original post, it did say:

"Add the following to both the after update of the checkbox and current
event of the form"
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
J

John Vinson

If you read my original post, it did say:

"Add the following to both the after update of the checkbox and current
event of the form"

Sorry Arvin - was reading too hastily!

John W. Vinson[MVP]
 
Top