Automatically Generating Users

Walk_The_Line

Registered User.
Local time
Today, 14:51
Joined
Aug 14, 2007
Messages
17
So i've got one thing done, the auto date, but I have a few different users for this dbase, and I need to get some kind of security feature for when somewone is adjusting records in the dbase.

How do I go about doing this (like show which user did the editing last?)
 
This is how I got it done (with the help of folks from this site)

I created the following fields on my table
-SystemUserName
-RecordChangeDate
-SystemUserName1
-RecordChangeDate1


I put the following code in the after update event of my form
Private Sub Form_BeforeUpdate(Cancel As Integer)

' Log the change details to the Products table
'SystemUserName and RecordCHangeDate hold current change
'SystemUserName1 and RecordCHangeDate1 hold previous change

Me.SystemUserName1 = Me.SystemUserName
Me.RecordChangeDate1 = Me.RecordChangeDate
Me.SystemUserName = CurrentUser()
Me.RecordChangeDate = Now()

On Error GoTo ErrorOut

If (Me.FIeldNameHere & "" = "") Then
MsgBox "Division can't be left blank"
DoCmd.SetWarnings False
Cancel = True
DoCmd.SetWarnings True
End If

ErrorOut:

End Sub

So every time someone changes a thing on that form, it updates. In this particular db I'm using the cumbersome Access security (works fine once you get it done right) getting the current user from =CurrentUser() but you can also use your own table to authenticate against and get the logged user name from your own login form.
 

Users who are viewing this thread

Back
Top Bottom