I have a delete button to delete a selected record. In order to stop accidental deletions I have set the property of the delete button to:
Enabled = No
Then once a user unlocks the record, the button becomes enabled.
My question is how can I get the button to revert back to Enabled = No, after is has been used to delete a record??
I get error messages if I try to use:
Private Sub deleterec_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Dim frmMyForm As Form
Dim ctlMyCtls As Control
Set frmMyForm = Forms!RealForm
For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "unlockdelete" Then
ctlMyCtls.Enabled = False
editlock.Caption = "UNLOCK RECORDS"
Me.refresh
End If
Next ctlMyCtls
Exit_deleterec_Click:
Exit Sub
Err_deleterec_Click:
MsgBox Err.Description
Resume Exit_deleterec_Click
End Sub
The Error message I get is: "2164; Can't disable control while it has focus"
ANy suggestions on how I can get around this??
Thnx
Enabled = No
Then once a user unlocks the record, the button becomes enabled.
My question is how can I get the button to revert back to Enabled = No, after is has been used to delete a record??
I get error messages if I try to use:
Private Sub deleterec_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Dim frmMyForm As Form
Dim ctlMyCtls As Control
Set frmMyForm = Forms!RealForm
For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "unlockdelete" Then
ctlMyCtls.Enabled = False
editlock.Caption = "UNLOCK RECORDS"
Me.refresh
End If
Next ctlMyCtls
Exit_deleterec_Click:
Exit Sub
Err_deleterec_Click:
MsgBox Err.Description
Resume Exit_deleterec_Click
End Sub
The Error message I get is: "2164; Can't disable control while it has focus"
ANy suggestions on how I can get around this??
Thnx