Last edited by userid / WNetGetUser function

blinville

New member
Local time
Yesterday, 19:07
Joined
Aug 7, 2002
Messages
5
OK, here is my problem. I created a form to be used on our intranet in Access to imput and edit customer data. I would like to be able to add a section on the form that grabs the Win / Lan user ID of the person making the change. I have a program I made way back when in VisualBasic 6.0 I called the get user program. It is a very simple exe that uses windows WNetGetUser function. Anyhow, I added a field in my table to store the ID and a putton with VB code that is suposed to be using my little program (wich works fine on it's own). This is ware my problem starts. I can not import it into the Access VB code builder (it errors on the import) and when I manually type the code in, it fails every time with a compile error. I am by no means an expert on VB and a far shot from what most of you would call a programer (I am a system analyst). Does anyone have any sugustions as to how you can 'tag' a record with who edited it last? Especialy from the form view.

Thanks
Ben:confused:
 
I use this to grab the users network ID...

Public Declare Function GetUserName Lib "AdvAPI32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetNTUser() As String
On Error GoTo Err_GetNTUser
Dim strUserName As String
strUserName = String(100, Chr$(0))
GetUserName strUserName, 100
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
GetNTUser = StrConv(strUserName, vbProperCase)
Exit_GetNTUser:
Exit Function
Err_GetNTUser:
MsgBox "GetNTUser", Err.Number, Err.Description
Resume Exit_GetNTUser
End Function

Then I have a field in the table named "ModifiedBy". I use this in the forms BeforeUpdate event...

Me.tbModifiedBy.Value = GetNTUser & " " & Date & " " & time

HTH
 

Users who are viewing this thread

Back
Top Bottom