Disable/Enable Form Objects With Code

A

Alias

Hello again,

When my form is on a new record, I would like this to happen:

1. Have combo box named FullName be enabled, but all other objects disabled.
2. When FullName is populated, enable all other form objects.

What code do I need to achieve this?

Thanks to all the Access Guru's in advance :)

-Alias
 
M

Marshall Barton

Alias said:
When my form is on a new record, I would like this to happen:

1. Have combo box named FullName be enabled, but all other objects disabled.
2. When FullName is populated, enable all other form objects.


First let's identify the controls that you want to disable
by setting their Tag property to PIG. (Don't forget that
some objects do not have an enabled property and attached
labels will be disabled along with their parent control.)

Use the form's Current event to check for a new record:

Dim ctl As Control
If Me.NewRecord Then
For each ctl In Me.Controls
If ctl.Tag = "PIG" Then ctl.Enabled = False
Next ctl
End If

Use the combo box's AfterUpdate event to enable them:

Dim ctl As Control
If Me.NewRecord And Not IsNull(Me.FullName) Then
For each ctl In Me.Controls
If ctl.Tag = "PIG" Then ctl.Enabled = True
Next ctl
End If
 
Top