Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control record updates by username...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I use two forms to add and update user records in a table. When a user adds a record in the "add" form, I use a function to get the winlogon username from the system and fill in a "username" field. In the "update" form, I want the user to be able to view all records, but how can I (if possible) restrict whether a user can update a record or just view it based on their username?
 
To restrict operations on recordsets, you really should set up MS. Access security. This is soewhat 'painful' and you need to read the directions carefully and proceed with extreme caution (inital set up ONLY on an isolated machine with a backup copy of everything at each step ... )

Once you have this set up, assing each user to the group(s) they need to be in for various operations (Read Only; Modify; Delete; Add). You can even have groups which will ahve different 'permissions' for different tables. (You COULD extend this to specific fields, but I have never seen this actually done).

Once the security groups are set up and users are assigned to the appropiate groups, You need to code each operation to check the user's group and permissions before allowing the operation.

This is a non trivial operation, but it does include the benefit of providing complete control over the operations on the data set and the mechanisim to generate a transaction log of all operations - which can include the User's name, date/time stamp and the machine Id. If you need the protection of user security, this is a good way to go.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Without getting into Access security yet, would it be possible to use the form's BeforeUpdate property to validate the username and allow or cancel the record update?
 
Yes,

BUT then you need to code each form for every username/permissions. This is - for most real world apps - more effort than enabling and using the security. This is especially true w/ regards to updates.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
If you are using Access 2000 check out &quot;Conditional Formatting&quot;. As long as the username is in the record, in conditional formatting fields can be enabled or disabled, and color changed. You would need to put the condition on each field in the record. it allows you to either put in an expression or check the value of the field you are on. For example, on each field you could put in the expression username<>currentuser(), then disable field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top