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
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