Changing the enabled state of an object after an event

morlan

Registered User.
Local time
Today, 04:50
Joined
Apr 23, 2003
Messages
143
If a certain event happens it will change the enabled property of an object eg.

If me.txtAge < 18 Then

me.txtName.Enabled = No

Any ideas
 
That about right. Just need to add the End If.

If me.txtAge < 18 Then
me.txtName.Enabled = No
End If

I think the only caveat is that the control being disabled cannot have the Focus at the time of disablement.

Hope this helps.

The Missinglinq
 
Place the code in the LostFocus() event

Private Sub txtAge_LostFocus()
If Me.txtAge < 18 Then
Me.ANOTHERCONTROL.SetFocus
Me.txtAge.Enabled = False
End If
End Sub

IMO
 
The code should be in the Form_Current event and "called" in the AfterUpdate event of txtAge, otherwise if users don't tab into and out of txtAge the code will not work, assuming you want the condition to work for existing records as well that is
 

Users who are viewing this thread

Back
Top Bottom