Evening guys.
Here something that's been driving me nuts for the past couple of hours.
I have a mainform and in it, two subforms. Normally I'd like the fields to be read-only, but if a user has the right password he'd be able to click on a button on the mainform and turn the "locked" property on all the fields to FALSE.
Code:
Pretty straightforward ..but no good so far...:(
The button unlocks the MAIN form's fields okay, but then I get this: "Run-time error '2465': Mainform can't find the field 'txtPrice' referred to in your expression."
An ideas? Thanks for the help!
Here something that's been driving me nuts for the past couple of hours.
I have a mainform and in it, two subforms. Normally I'd like the fields to be read-only, but if a user has the right password he'd be able to click on a button on the mainform and turn the "locked" property on all the fields to FALSE.
Code:
Code:
Private Sub cmdEdit_Click()
Dim strPasswd
strPasswd = InputBox("Please insert the password to edit records", "Access restricted")
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "Cancelled.", vbInformation, "Insert password."
Exit Sub
End If
If strPasswd = "password1" Then
'unlocks fields in main forms
Me!cmdNewRecord.Enabled = True
Me!txtSubject.Locked = False
'unlocks fields in subform 1
Me!subAquisitions.Form!txtPrice.Locked = False
'unlocks fields in subform 2
Me!subResponsible.Form!txtName.Locked = False
Else
MsgBox "Sorry, wrong password.", _
vbOKOnly, "Try again"
Exit Sub
End If
End Sub
The button unlocks the MAIN form's fields okay, but then I get this: "Run-time error '2465': Mainform can't find the field 'txtPrice' referred to in your expression."
An ideas? Thanks for the help!
Comment