Dear Sir
I have form “Rcvd_Main_1” and subform “Rcvd_detail1_subform_1”.
The field of subforms are:
S_P_ID (Combo box to select the items),
STATUS(combo box to select IN or out)
O_BAL1: (Opening balance)
QTY_IN: (Rcvd qty)
QTY_OUT: (Issue qty)
C_BAL: (Closing balance)
I have changed the control property of subform from Enable to No and Locked to Yes.
When I open the main form the fields are locked.
I have placed two button LOCK and UNLOCK on main form. When I click on UNLOCK it changes the properties of Enable to Yes and Locked to, to feed the inputs. But when I click on UNLOCK the message “Run-time error 2164 You can’t disable a control while it has the focus”
In combo box there is lost focus or get focus I placed. The codes on LOCK button is:
Private Sub txtPassword_AfterUpdate()
Const MESSAGETEXT = "You are not allowed access to the ''""Special Form""'"
Dim Frm As SubForm
Dim ctrl As Control
Set Frm = [Forms]![Rcvd_Main_1]![RCVD_DETAIL1_subform1]
If Me.txtPassword = "Farooq" Then
For Each ctrl In Frm.Controls
If ctrl.Tag = "EditMe" Then
ctrl.Enabled = False
ctrl.Locked = True
End If
Next ctrl
DoCmd.Close acForm, Me.Name
Else
MsgBox "Incorrect Password!" & vbCrLf & vbCrLf & MESSAGETEXT, vbCritical, "Invalid Password"
DoCmd.Close acForm, Me.Name
End If
End Sub
Please advise how to handle this error to resolve.
Regards
Muhammad Farooq