Selasa, 24 Juli 2012

[MS_AccessPros] Re: updating records

 

Thomas

To answer your second question, use the formn's AfterUpdate event. Put hidden (or visible) text boxes bound to your ModifiedDate and ModifiedBy fields.

If you are not using a workgroup (User Level Security) you will have to get the user ID with an API call. The date can be assigned using the Now() function.

Example of API call:

'Put this in the general declarations section of your form's code.
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

'This is the function that gets the usser ID.
Public Function CurrentUserName() As String
'Purpose : Returns the network login name
'DateTime : 5/28/2002 09:54
'Author : Bill Mosca
Dim lngLen As Long
Dim x As Long
Dim strUserName As String

'Create buffer
strUserName = String(254, Chr$(0))
lngLen = Len(strUserName)
x = GetUserName(strUserName, lngLen)

If (x > 0) Then
'Trucate remaining buffer space from end of string.
CurrentUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
Else
CurrentUserName = vbNullString
End If

End Function

Let us know if you need help with this.

Regards,
Bill Mosca

--- In MS_Access_Professionals@yahoogroups.com, "Thomas" <thomas_lam_us@...> wrote:
>
> How can I update the record(s) to include a time-stamp field updated and the userid when the record is updated via the form?
>
> The form allows for edit and filter only. After the record(s) are updated on the form, the updated information does not reflect on the on the form immediately. I notice the updated information is displayed after I close and reopen the form. So I know the affected rows are updated by Access.
>
> Is there any way to force the update to be displayed immediately on the form after the rows are being updated?
>
> If I want to include some additional information, such as the time-stamp at the time of the update and the userid etc, as part of the record update, what event will allow me to included this before Access update the row(s) ?
>
> Regards,
> Thomas
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar