Jim,
Consider setting the default value of the text box to the user rather than the value.
Duane Hookom, MVP
MS Access
Sent: Wednesday, September 28, 2016 11:14 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Create row user log
Hello all,
We have a database that has 1 backend and 6 frontends. Someone keeps adding a blank record and no one is admitting it. I believe that it is either a bug or probably user error. I opt to think that it is user error.
I would like to create a user log for any new record being added to the table. I have part of the solution but a piece of the parts is doing something I am unsure of.
On the form load event for the form I have the following code to populate a text box named txtUser with the user log. this works wonderful. The issue is when I click the add new button on the form the record is added and the date and the log in are populated, but the txtUser control goes blank. I am then unable to use the add new record button to get the data to put in the table. I am unable to explain why the text goes away.
I added the same code for the environ to the form load event also and the text disappears in the control.
Is there something I am missing or I am on the wrong track going to the wrong town?
Thank You
Jim Wagner
Form Load Event
Private Sub Form_Load()
Me.txtUser = Environ("UserName")
End Sub
__________________________________
On the before update event of the form I have the following code
Private Sub Form_BeforeUpdate(Cancel As Integer)
CurrentDb.Execute "INSERT INTO [Essential Functions] (DateofEdit, User) " & _
"Values(Date() + Time(), '" & Me.txtUser.Value & "')", dbFailOnError
Me.txtUser = Environ("UserName")
End Sub
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar