By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,686 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Tack Changes II

P: n/a
Hello:

I already posted a question yesterday concerning that problem and got
help, however I was not able to fix it entirely. I want to track when
updates were made and who did it using the general networkID.
Here is what I did:

I created the following module:

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

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
End Function
'******************** Code End **************************

Then I created the following procedure for my form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[ModifyDate] = Now
Me.[ModifiedByUser] = UserName
End Sub

Private Sub ModifiedByUser_AfterUpdate()
End Sub

Private Sub ModifyDate_AfterUpdate()
End Sub

I get the ModifyDate, but not ModifiedByUser, I appreciated any
suggestions

Thanks a lot Nicole
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
In your Form_BeforeUpdate, you are referencing something called "UserName".
If this is supposed to be the API you have listed at the top, the function
name is called "fOSUserName".

Mike Storr
www.veraccess.com

"Nicole" <nv****@gmx.de> wrote in message
news:72**************************@posting.google.c om...
Hello:

I already posted a question yesterday concerning that problem and got
help, however I was not able to fix it entirely. I want to track when
updates were made and who did it using the general networkID.
Here is what I did:

I created the following module:

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

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
End Function
'******************** Code End **************************

Then I created the following procedure for my form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[ModifyDate] = Now
Me.[ModifiedByUser] = UserName
End Sub

Private Sub ModifiedByUser_AfterUpdate()
End Sub

Private Sub ModifyDate_AfterUpdate()
End Sub

I get the ModifyDate, but not ModifiedByUser, I appreciated any
suggestions

Thanks a lot Nicole

Nov 12 '05 #2

P: n/a
Thanks for your quick response!

I already tried that and I知 getting a Compile error: Expected variable
or procedure, not module. I知 sorry; I知 really new in the Access field.

Thanks Nicole
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

P: n/a
On 27 Jan 2004 18:49:10 GMT, Nicole Voigt wrote:
Thanks for your quick response!

I already tried that and I知 getting a Compile error: Expected variable
or procedure, not module. I知 sorry; I知 really new in the Access field.

Thanks Nicole
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


I'm thinking that your code of
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[ModifyDate] = Now
Me.[ModifiedByUser] = UserName
End Sub

should read

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[ModifyDate] = Now
Me.[ModifiedByUser] = fOSUserName
End Sub

--
Mike Storr
veraccess.com
Nov 12 '05 #4

P: n/a
I'm sorry, I tried that too and it won't work, I get still the compiling
error. Thanks Nicole
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5

P: n/a
When you get the compile error, it should indicate what line is causing it.
If you could post that this may make more sense.
"Nicole Voigt" <nv****@gmx.de> wrote in message
news:40***********************@news.frii.net...
I'm sorry, I tried that too and it won't work, I get still the compiling
error. Thanks Nicole
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #6

P: n/a
Thanks for your help, the problem was that I named the module like my
variable and that of course would not work. Thanks a lot Nicole

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7

P: n/a
Look to see if you have a module called fOSUserName, if you have change the
name to (e.g. modOSUserName) something else

Terry
"Nicole Voigt" <nv****@gmx.de> wrote in message
news:40***********************@news.frii.net...
I'm sorry, I tried that too and it won't work, I get still the compiling
error. Thanks Nicole
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.