Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    function valid for any form (Access 2000)

    I need to build a function valid for all forms and making all the controls on the form locked and with no edits as in:
    public function allow (frm as Form)
    For each control in frm
    AllowEdits = false
    Locked = true
    End Function


    Can somebody help me make the above code really working?

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: function valid for any form (Access 2000)

    try something along the lines of

    <font face="Georgia">Public Function LockForm (frm as Form, blnLocked as Boolean)
    dim ctl As Control

    frm.AllowEdits = not blnLocked
    For each ctl in frm.Controls
    ctl.locked = blnLocked
    Next ctl
    End Function</font face=georgia>

    You need two pass to variables to this function.
    frm is the actual Form object (not just the form name)
    blnLocked the value TRUE or FALSE depending on whether you wish to lock the form or unlock the form

    Give this a try. Hope that it helps.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: function valid for any form (Access 2000)

    Looks like Jayden is spot on. Attached is an example with a slight difference in the function that does the work: I pass in the name of the Form, whereas Jayden uses the Form object. Either way will do the trick. Best of luck.
    Attached Files Attached Files
    <font face="Comic Sans MS"><font color=blue>~Shane</font color=blue></font face=comic>

  4. #4
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: function valid for any form (Access 2000)

    Thank you very very much for your reply.How shall i call this function in the OnOpen event of the form?
    i have tried this:
    LockForm (me,blnLocked)
    or
    LockForm(Me.Name,BlnLocked)
    but i received errors.


    Best regards

  5. #5
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: function valid for any form (Access 2000)

    If using my example it should be
    LockForm(me, TRUE) to lock the form
    or
    LockForm(me, FALSE) to unlock the form

Posting Permissions

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