network userID to auto populate field when record is created/revis

S

slickdock

I would like the currently logged in windows user name to autopopulate the
[LastRevisedBy] field in a record. I am aware of, and have the code that
returns the network login name (see below). My question is, how do I have
the [LastRevisedBy] field in my form fill in with that info when the record
is revised? I am a newbie at VBA, so please go easy on me. Thank you.

Function fOSUserName() As String
' Returns the network login name
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 = vbNullString
End If
 
P

pietlinden

I would like the currently logged in windows user name to autopopulate the
[LastRevisedBy] field in a record. I am aware of, and have the code that
returns the network login name (see below).  My question is, how do I have
the [LastRevisedBy] field in my form fill in with that info when the record
is revised?  I am a newbie at VBA, so please go easy on me.  Thank you.

Function fOSUserName() As String
' Returns the network login name
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 = vbNullString
    End If

put the code in the beforeUpdate event of the FORM to update that
LastModifiedBy field.
 
S

slickdock

I would like the currently logged in windows user name to autopopulate the
[LastRevisedBy] field in a record. I am aware of, and have the code that
returns the network login name (see below).  My question is, how do Ihave
the [LastRevisedBy] field in my form fill in with that info when the record
is revised?  I am a newbie at VBA, so please go easy on me.  Thank you.
Function fOSUserName() As String
' Returns the network login name
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 = vbNullString
    End If

put the code in the beforeUpdate event of the FORM to update that
LastModifiedBy field.- Hide quoted text -

- Show quoted text -

I know WHERE to put the code (beforeUpdate), but I don't know WHAT
code to put there exactly.
 
D

Douglas J. Steele

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me.LastModifiedBy = fOSUserName()

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


On Sep 24, 7:06 pm,slickdock<[email protected]>
wrote:
- Show quoted text -

I know WHERE to put the code (beforeUpdate), but I don't know WHAT
code to put there exactly.
 
S

slickdock

Private Sub Form_BeforeUpdate(Cancel As Integer)

  Me.LastModifiedBy = fOSUserName()

End Sub

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)




I know WHERE to put the code (beforeUpdate), but I don't know WHAT
code to put there exactly.

you da bomb! Thanks for that and for so much other help you have given
me over time.
 

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

Similar Threads


Top