Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Enabled Property after Lost Focus

Status
Not open for further replies.

ohmbru

Technical User
Jul 13, 2001
161
US
I'm trying to set the Enabled and Locked properties of a field after the users moves to another field.

The form is set up to time stamp the field with the current time on the OnClick event. If the user wants to change the time they need to click a button which flags the record indicating they did not use the system time.

The field is enabled and unlocked when they click the change button. The AfterUpdate event disables and locks the field again.

The flaw is when the user clicks the change button and decides to not make any changes by moving to another field, the field is not disabled and locked.

I attempted to use the LostFocus event but it would not allow me to set the Enable property to False when the field has the focus.

These first 2 events work as expected:

Private Sub cmdIn1_Click()
ChgInd = "Y"
Me!In1.Enabled = True
Me!In1.Locked = False
DoCmd.GoToControl "in1"
End Sub

Private Sub In1_AfterUpdate()
If ChgInd = "Y" Then
Me!ChgIn1 = "*"
Else: Me!ChgIn1 = ""
End If
DoCmd.GoToControl "Comments"
ChgInd = "N"
Me!In1.Enabled = False
Me!In1.Locked = True
End Sub

I've tried to control things (unsuccessfully) with these events:

Private Sub In1_Exit(Cancel As Integer)
ChgInd = "N"
Me!In1.Enabled = False
Me!In1.Locked = True
End Sub

Private Sub In1_LostFocus()
ChgInd = "N"
Me!In1.Enabled = False
Me!In1.Locked = True
End Sub


Brian
 
Hi Brian,

I think all you should need to do is SetFocus to a different control in your Lost_Focus event before setting the control's Enabled property to false, something like this:

Private Sub In1_LostFocus()
ChgInd = "N"
Me!AnotherControlOnForm.SetFocus
Me!In1.Enabled = False
Me!In1.Locked = True
End Sub

Let me know if this helps


Regards,
gkprogrammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top