Network Login Username, Created and Modified Date

F

Fanta Orange

I have read through all of the posts and references to
http://www.mvps.org/access/api/api0008.htm
However, I need to take VB 101, but don't have the time right now. In a
table when a new record is created I want to auto-populate 3 fields when a
user finishes creating/editing a record.
(1) Network Login Username (2) Record Created Date and (3) Record Modified
Date. I know that I am asking much, but can someone give me some A-Z
instructions for VB idiots (novices).
I wonder why they did not make these built-in functions of Office 2007?
 
P

Pete D.

For the record create date just put Date() in the tables field as the
defualt value and make the field on the form enabled no and locked yes to
prevent user changing it on the form.

Username go back to that site and copy and past fOSUserName into a new
module. Compile it and test save it. Module save name cannot be same as the
function name above.

Put =fLastModified() in the before update of the form.


Copy and past below into new module and compile save it. Note M_ is module
name f is function name.

Option Compare Database
Option Explicit
'------------------------------------------------------------
' M_LastModified
'------------------------------------------------------------
Function fLastModified()
On Error GoTo fLastModified_Err
With CodeContextObject
' Field Name
.DateModified = DATE
' .TimeModified = Time()
.UserLogon = fOSUserName()
' .MachineName = fOSMachineName()
End With
fLastModified_Exit:
Exit Function
fLastModified_Err:
MsgBox Error$
Resume fLastModified_Exit
End Function
 
Top