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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data about current user, permission to edit data

Status
Not open for further replies.

Ryama

Programmer
May 19, 2007
4
SK
Hello. I want to apologize for my english. I am the beginner in MS Access and VBA too. Please I need to help with this problems with my database:
1. I need to detect who last user modified the record in the table and this data to write to the same table (name of user, date of modification).
2. One form is opened for read only for every users, but I need wheh specific user clicked on cmd button "edit" on this form, then he can edit the records in this form. How can I do it?
Thank you for your help.
 



Hi,

You might get a better response in one of the many MS Access Forums like Forum705.

"...I need to detect who last user modified the record in the table ..."

What if tht change happened 2 years ago? You better have a field in each table with Date/Time-Stamp and an Changed By ID fields.

"...I need wheh specific user clicked on cmd button "edit" on this form..."

This can be done in the Button_Click event.

Skip,

[glasses] [red][/red]
[tongue]
 
Assumptions: you have a form based on the table and two bound controls named txtUser and txtLastUpdate.

1. In the BeforeUpdate event procedure of the form:
Code:
Me![txtUser] = CurrentUser 'comment out if the DB is NOT secured
Me![txtUser] = Environ("UserName") 'comment out if the DB IS secured
Me![txtLastUpdate] = Now

2. In design view the form is made read only (AllowEdits, AllowAdditions and AllowDeletions set to false)
In the Click event procedure of the button:
Code:
If [i]test the user name here[/i] Then
  Me.AllowEdits = True
Else
  MsgBox "Form is read only"
End If
and in the Current event procedure of the form:
Code:
Me.AllowEdits = False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Many thanks both of you. I try it on Mondey when I will be in my office. After I write if I was successfull. Bye and thanks.
 
Hi, its me. PHV, thank you very much for your help. All your advices work perfectly! However, I still have one similar problem with editig, adding and deleting records in subform, when it used by specific user (XY).

In the Current Event procedure of this form is:
Me.AllowEdits = False
Me.AllowAdditions = False
Me.AllowDeletions = False

If CurrentUser = "XY" Then
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = True
End If


It does not works, User can edit data, but does not add or delete them. Plese, can you help me, where do I mistake? Thanks for your helpfulness.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top