Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    lock a form exclude one field (2003)

    Hello,
    With help from Hans I managed to lock a form with the 2 subforms on base of the yes/no (ynvoldaan) field in the first subform.
    But I thought it would be better if I can unlock just that one yes/no field (ynvoldaan). Because if it was set on on "true" by mistake I has to be possible to undo it!

    Is it possible to lock the form exlcuded one field?

    Many thanks on advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: lock a form exclude one field (2003)

    Hello plutoken,

    If Allow Edits is set to No, *all* controls on a form are locked, you cannot unlock a single control. Here are two possible ways to solve this problem

    1) Leave Allow Edits set to Yes, and set the Locked property of all editable controls except ynVoldaan to True or False depending on the value of ynVoldaan. This way, ynVoldaan can be changed at all times, but it is a lot of work.

    2) Put a command button on the first subform (or on the main form) with caption "Unlock form". In the On Click event procedure of the command button, set the AllowEdits property of the form and subforms to True. The user can then edit all controls, including ynVoldaan. When the user moves to another record, the code you already have will turn off Allow Edits again if necessary.

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: lock a form exclude one field (2003)

    Hello,
    Like you said, it would be a lot of work to lock every field on it.
    So I did put a button on the mainform to unlock everything.

    But now I have the problem that even when by the value of "false" on the yn field, the 2de subform remains locked.
    How do I refresh the 2de subform?

    thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: lock a form exclude one field (2003)

    Try changing the code from <post:=695,131>post 695,131</post:>

    Private Sub Form_Current()
    On Error GoTo form_Err
    If Forms!frmfacturatie!FacturatieHidden.Form!ynVoldaa n Then
    Me.subFrmFacturatie.Form.AllowEdits = (Me.ynVoldaan = False)
    Me.subFrmFacturatie.Form.AllowAdditions = (Me.ynVoldaan = False)
    Me.subFrmFacturatie.Form.AllowDeletions = (Me.ynVoldaan = False)
    Forms!frmfacturatie!lblLocked = "Deze factuur kan niet bewerkt worden, daar ze reeds voldaan is!"
    Else
    End If
    form_End:
    Exit Sub
    form_Err:
    Resume form_End

    Resume form_End
    End Sub

    to

    Private Sub Form_Current()
    On Error GoTo form_Err
    Me.subFrmFacturatie.Form.AllowEdits = (Me.ynVoldaan = False)
    Me.subFrmFacturatie.Form.AllowAdditions = (Me.ynVoldaan = False)
    Me.subFrmFacturatie.Form.AllowDeletions = (Me.ynVoldaan = False)
    If Me.ynVoldaan Then
    Forms!frmfacturatie!lblLocked = "Deze factuur kan niet bewerkt worden, daar ze reeds voldaan is!"
    Else
    Forms!frmfacturatie!lblLocked = ""
    End If
    form_End:
    Exit Sub
    form_Err:
    Resume form_End
    End Sub

  5. #5
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: lock a form exclude one field (2003)

    Yes thanks, that works just fine.
    But I don't understand the differents.

    Many thanks,

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: lock a form exclude one field (2003)

    In the original code

    If Forms!frmfacturatie!FacturatieHidden.Form!ynVoldaa n Then
    Me.subFrmFacturatie.Form.AllowEdits = (Me.ynVoldaan = False)
    ...

    the AllowEdits property is only set if ynVoldaan is True. If ynVoldaan is False, the line that sets AllowEdits is skipped. I moved the If ... Then line down, so that AllowEdits is always set.

Posting Permissions

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