Add a Boolean (Yes/No) Approved field, a date/time ApprovedDateTime field and
a text ApprovedBy field to the underlying table.
Add a check box to the form with the Approved field as its ControlSource and
in the check box's AfterUpdate event procedure put the following code:
If Approved Then
Me. ApprovedDateTime = Now()
Me.ApprovedBy = GetUser()
Else
Me. ApprovedDateTime = Null
Me.ApprovedBy = Null
End If
If the user checks the check box the current date and time will be assigned
to the ApprovedDateTime field and the user name to the ApprovedBy field. If
the user unchecks the check box, i.e. 'unapproves' the action then both
fields will be cleared to Null. The GetUser function calls the Windows API
to return the user name of the currently logged in user, for which you need
to add the following module to the database:
''''module starts''''
Option Compare Database
Option Explicit
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long
Public Function GetUser() As String
Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long
lngSize = 199
strBuffer = String$(200, 0)
lngRetVal = GetUserName(strBuffer, lngSize)
GetUser = Left$(strBuffer, lngSize - 1)
End Function
''''module ends''''
If you have implemented Access user and group level security then you can
alternatively get the name with which the current user is logged into Access
with:
Me.ApprovedBy = CurrentUser()
and would not need the module to call the Windows API.
Ken Sheridan
Stafford, England