Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    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"
    Exit Sub
    End If

    ' 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
    End If
    End If
    End Sub

    Many thanks
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 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)
    With Me.FrmOUT0506Sub.Form
    .AllowAdditions = f
    .AllowDeletions = f
    .AllowEdits = f
    End With
    End Sub
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts