Access app: Restrict editing records by user


The following example demonstrates how to toggle the enabled property for the edit/delete action bar buttons on a form/view in relation to the current user.

 

Within SharePoint, create a new Access app

In the Add Tables, search for and select the Orders template

 

Create a Data Macro to lookup the employee’s ID based on their email address

Create an On Start macro. This macro stores the current user’s email address in a variable and then calls a data macro to lookup the employee’s ID based on the email address. If the email address is found in the Employees table, the employee ID is returned and stored in another variable.

Open the Orders List view in design view. Then create an On Current event. This code checks if the employee id we've stored in the varUserEmployeeID variable matches the Employee.ID for the current record. If so, the action bar buttons are enabled. Otherwise the buttons are disabled.

Populate the tables with data

Test the solution. Since I’m logged in as Dennis Wi, the edit/delete buttons are enabled when order 2 is selected but greyed out on the other records.



Comments (3)

  1. Shaun Parfett says:

    Many thanks. Very helpful article. Access Web Apps are awesome.

  2. Christopher says:

    I get a "Invalid Control Reference: Error 2055"

  3. lee says:

    Does not work on DataSheet view as user can still right mouse click and click delete

Skip to main content