Results 1 to 3 of 3

Lock field with VBA

  1. #1
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    35

    Lock field with VBA

    Is there a way I lock one or two fields on a Form based on user Access level?

    We are trying to prevent Users from making changes to Fields A and B (just examples) but allow them to make changes on the rest of the form, while not restricting Admins.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    5,055
    I have a tUsers table, userID,name,Level
    when the main form opens, I get userID:
    txtUser= environment("userName")

    then I lookup the level,
    txtLevel=Dlookup("[level]","tUsers","[userId]='" & me.txtUser & "'") & ""

    now I lock fields according to level...
    A,admin has all rights,M,manager has some, U,user get view only.

    txtCity.locked= txtLevel="U"
    txtName.locked = txtLevel<>"A"

  3. #3
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    35
    ranman256...will I add the Dlookup("[level]","tUsers","[userId]='" & me.txtUser & "'") & "" to my login page or to the form I want to lock those fields?

    I have two tables a tblUsers with: EmployeeID | Name | EmployeeTypeID
    and
    tblUserType with: ID | EmployeeType

    Using the DLookup would it read: Dlookup("[EmployeeTypeID]","tUsers","[EmployeeId]='" & me.txtUser & "'") & ""

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

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2016, 06:29 AM
  2. Lock field after auto date fill
    By DCV0204 in forum Forms
    Replies: 4
    Last Post: 11-25-2013, 07:53 AM
  3. Lock a field on a form
    By pbouk in forum Forms
    Replies: 3
    Last Post: 03-25-2013, 09:45 PM
  4. Lock a field after data has been entered
    By winterh in forum Forms
    Replies: 8
    Last Post: 03-15-2012, 02:32 AM
  5. Replies: 3
    Last Post: 03-13-2012, 11:02 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
  •  
Tech Forums: Microsoft Office Forums