• function valid for any form (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » function valid for any form (Access 2000)

    Author
    Topic
    #362978

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #552591

      try something along the lines of

      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

      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.

      • #552656

        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

        • #552661

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

    • #552592

      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.

    Viewing 1 reply thread
    Reply To: function valid for any form (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: