Results 1 to 2 of 2
2008-07-19, 20:57 #1
- Join Date
- Jul 2008
- Suffolk, United Kingdom
- Thanked 0 Times in 0 Posts
restricted editing of a subform (2003)
I have a form called TblIncompletes which has as subform called FrmOUT0506Sub I want to restrict edits to the subform to standard users by using the an event to request a password when the user attempts to edit the subform.
I can only get it working for one specfic field at a time, is there a way of making the entire subform use my code below.
Private Sub CRN_KeyDown(KeyCode As Integer, Shift As Integer)
Dim strInput As String
'If the field is not flagged for editing, prompt the user
'for confirmation about unlocking the control.
If fEditCRN = False Then
strInput = InputBox("Enter Access code")
' Check if value is entered into InputBox
' If no value entered display MsgBox
If strInput = "" Or strInput = Empty Then
MsgBox "No Input Provided", , "Access Code Required"
' Check InputBox value and if value is a match
' display tab and unhide hidden fields
If strInput = "password" Then
'If the response is Yes, unlock the field
'and flag it as being edited.
Me!CRN.Locked = False
fEditCRN = True
Gerbil (AKA Kevin)
2008-07-19, 21:25 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: restricted editing of a subform (2003)
I'd put the code to ask for the password in the On Open event of the main form:
Private Sub Form_Open(Cancel As Integer)
Dim strPassword As String
Dim f As Boolean
strPassword = InputBox("Enter the password if you want to be able " & _
"to edit records in the subform")
f = (StrComp(strPassword, "PasSwOrD", vbBinaryCompare) = 0)
.AllowAdditions = f
.AllowDeletions = f
.AllowEdits = f
You could put a command button "Edit Subform" on the main form instead.
You can add message boxes to inform the user of the state of the subform.
Note: this is not very secure. It's easy to discover the password.