Adding the user's name to a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I can capture the user that is logged into my database. I would like to take that information and update the table with this person. I have already figured out how to get the current date/time. Now I just need to know how to get the person in there. Why do I want to do this? I want to do this so I know who is accessing my database so if they compain that they don't have the information that they need then I can check to see if they have looked for the information in my database
Here's my code and my table is called tblUsers with a field called Users that I want to add to

Declare Function wu_GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Lon
Function ap_GetUserName() As Varian


Dim strUserName As Strin
Dim lngLength As Lon
Dim lngResult As Lon

'-- Set up the buffe
strUserName = String$(255, 0
lngLength = 25

'-- Make the cal
lngResult = wu_GetUserName(strUserName, lngLength

'-- Assign the valu
ap_GetUserName = strUserNam

' Put user name into the tblUser

Thanks June
 
Access doesn't allow you to use user-defined functions as default values in
tables. Your only option is to use a form for input: then, you can set the
default value of the textbox on the form to that function (or else set the
field's value in the form's BeforeUpdate event)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


June said:
Hi,
I can capture the user that is logged into my database. I would like to
take that information and update the table with this person. I have already
figured out how to get the current date/time. Now I just need to know how
to get the person in there. Why do I want to do this? I want to do this so
I know who is accessing my database so if they compain that they don't have
the information that they need then I can check to see if they have looked
for the information in my database.
 
If you are using user level security you can set a table field default value to the internal function CurrentUser(), the same way you can set the default of a datetime field to Now().
 
Back
Top