Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to toggle the enabled property from a button (2003)

    Hi,

    I would like to be able to toggle the enabled property of a subform on or off with a command button on the parent form. I would like it to pop up asking for a code, although this is not very secure it is only to prevent accidently modifing the subforms datasheet

    Thanks
    Regards
    Gerbil (AKA Kevin)

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

    Re: How to toggle the enabled property from a button (2003)

    In a variation of the code in <post:=722,585>post 722,585</post:>:
    <code>
    Private Sub Form_Open(Cancel As Integer)
    Dim strPassword As String
    Dim f As Boolean
    strPassword = InputBox("Enter the password")
    f = (StrComp(strPassword, "PasSwOrD", vbBinaryCompare) = 0)
    Me.FrmOUT0506Sub.Enabled = f
    End Sub
    </code>
    As in the previous code, FrmOUT0506Sub must be the name of the subform as a control on the main form; this is not necessarily the same as the name of the subform in the database window. Open the main form in design view and click once on the subform to see its name in the Properties window.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: How to toggle the enabled property from a button (2003)

    Rather then toggling the enabled property, I'd consider toggling the Locked property. Make Locked = True in current event of main form. This way, the user has access to the subform (scrolling, sorting, etc), but just can't make changes. And if this is merely to prevent accidental change (and is not really a security issue), I'd just have a command button that had to be clicked to unlock the subform.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to toggle the enabled property from a button (2003)

    Thank you thats a good idea, many thanks
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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