After Update Save

  • Thread starter Thread starter Cydney
  • Start date Start date
C

Cydney

I have a form that I want to force one of the fields to update with a
timestamp when any of the other field's data changes.

Private Sub Form_AfterUpdate()
Me.PESA_timestamp = CurrentUser() & " ~ " & Date
End Sub

When a change is made, it stays in the record and won't leave "Edit mode"
until I hit the ESC key. How can I get it to accept my changes and allow me
to proceed to the next record without manually hitting the ESC.

Also. .is there a way to get the Login Name rather than the PC user name?
--
Thank you, cs
~~~~~~~~~~~~~~~~~~~~~~~~
"What lies behind us and what lies before us are tiny matters compared to
what lies within us."
~ Ralph Waldo Emerson
 
One way is to put the timestamp code on the form's before update event.
If you don't want to do that, you can use the form's before update event to
check each control (one's you can edit) to see if any changes were made.
Only call the timestamp code in the form's after update event if you detect
that real changes were made in the before update event.

To get the login name, try this code

Public Function GetNetworkUserName() As String
'Purpose: Returns the network login name
'Return: The name, or "{Unknown}" on error.
'Note: Safer than testing Environ().

Dim lngLen As Long
Dim lngX As Long
Dim strUserName As String

strUserName = String$(254, 0&)
lngLen = 255&
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0&) Then
strUserName = Left$(strUserName, lngLen - 1&)
End If

If strUserName <> vbNullString Then
GetNetworkUserName = strUserName
Else
GetNetworkUserName = "{unknown}"
End If


End Function


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Back
Top