Results 1 to 3 of 3
  1. #1
    mainerain is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2018

    vba for changing AllowEdits on all Forms

    I want to have other people view my database without them being able to make edits to the data in any of my many forms. I was thinking of using a particular key stroke to AllowEdits for all forms. Is there a generic code to change all forms without having to name each form in the code to allow/disallow edits? Thanks

  2. #2
    Ajax is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Is there a generic code to change all forms without having to name each form in the code to allow/disallow edits?
    No. assuming you have a login process you can set a global 'EditingAllowed' boolean variable to true or false depending on the user 'rights'. Then in each form open event you can call a function to set the allowedits property in the form. You do not need to have code in each form, just call the function from the property. e.g.

    put this in a standard module

    Function fnAllowEdits(frm as Form)


    End Function
    then for each form open event property, instead of [Event Procedure] put


    Goes without saying that you have split the db and each user will have their own copy of the front end on their local machine so their global variable will only relate to them

  3. #3
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    May 2010
    Alappuzha, India
    Try this:
    Public Function NoEdits()
    Dim ctr As Container, doc As Document
    Dim db As Database, strForm As String
    Set db = CurrentDb
    Set ctr = db.Containers("Forms")
    For Each doc In db.Containers("Forms").Documents
        strForm = doc.Name
       DoCmd.OpenForm strForm, acDesign, , , , acHidden
       Forms(strForm).Properties("AllowEdits") = False
       DoCmd.Close acForm, strForm, acSaveYes
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. AllowEdits and Subforms
    By fret hack in forum Forms
    Replies: 2
    Last Post: 10-16-2017, 09:39 AM
  2. Changing Fonts on the fly in Forms
    By pharrison74 in forum Forms
    Replies: 2
    Last Post: 03-23-2016, 03:04 PM
  3. .allowEdits property
    By Lukael in forum Access
    Replies: 3
    Last Post: 11-23-2015, 12:49 AM
  4. Allowedits according to the record
    By lios1984 in forum Forms
    Replies: 4
    Last Post: 06-20-2012, 11:41 PM
  5. AllowEdits in Subform
    By Jackie in forum Forms
    Replies: 3
    Last Post: 03-02-2011, 10:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Other Forums: Microsoft Office Forums - Senior Forums