record the sign on

J

JayTee

Hi all,
I posted this on the formsprogramming but so far no response so I thought I
would try here.

I would like to know how I can record the username of an employee that has
signed onto our network.
We have a large Access Database with an Access front end and SQL backend on
which I would like to record the user Id on a field in some of the tables so
that we know who has created a particular record. I have already put in
place the date and time but we need to know the user ID.
All users use a username and a password to get onto the network

Any help would be tremendous and thanks in advance to anyone that can steer
me in the right direction.

J
 
G

Guest

Hi JayTee,

What do you mean by log on to the network by a username and a password? Do
you mean log into the database?

Do you have a security set up on your FE? If you do, you can use
"currentuser()" in the BeforeUpdate event of a form. For example, when a
user creates a new record through one of your forms, that record will be
documented with that user (e.g. jsmith). In order to record the user who
recorded, you must have a field (e.g. created by) in the table. Then, you
want to use the code "Me.[created_by]=currentuser()" (typically) in the
BeforeUpdate event of the form.

I hope that is what you are looking for.
 
G

Guest

Place the following in a standard module then just use =fOSUserName() to get
the current network username.

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
On Error GoTo fOSUserName_Err

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

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)

If lngX <> 0 Then
fOSUserName = left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If

fOSUserName_Exit:
Exit Function

fOSUserName_Err:
MsgBox Error$
Resume fOSUserName_Exit
End Function

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top