|  | Access 2007 when a record is modified, I want to store UserN |  | |
| | | unfortune8 |  |
| Posted: Wed Sep 03, 2008 1:54 pm Post subject: Access 2007 when a record is modified, I want to store UserN |  |
Now that there aren't user groups and permissions in 2007, how do I store the name of the person that has modified a record. |
| |
| | | ErezM via AccessMonster.c |  |
| Posted: Wed Sep 03, 2008 2:57 pm Post subject: Re: Access 2007 when a record is modified, I want to store U |  |
| |  | |
you need to add a ModifiedBy field to every table you need auditing for, and then pick the user name by an entry form that asks for the user name or you can tell the windows/network user name of the currenctly logged in user by
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
put all this in a module, so you can access it from anywhere in the db
unfortune8 wrote:
| Quote: | Now that there aren't user groups and permissions in 2007, how do I store the name of the person that has modified a record.
|
-- May all beings be happy.
Message posted via AccessMonster.com LINK |
| |
| | | unfortune8 |  |
| Posted: Wed Sep 03, 2008 5:05 pm Post subject: Re: Access 2007 when a record is modified, I want to store U |  |
| |  | |
Thanks for the response. Unfortunately, I'm not familiar with VB coding or working with modules. I've copied the code you gave into a module, but don't know where to go from there. If you can provide any additional direction, that would be great.
"ErezM via AccessMonster.com" wrote:
| Quote: | you need to add a ModifiedBy field to every table you need auditing for, and then pick the user name by an entry form that asks for the user name or you can tell the windows/network user name of the currenctly logged in user by
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
put all this in a module, so you can access it from anywhere in the db
unfortune8 wrote: Now that there aren't user groups and permissions in 2007, how do I store the name of the person that has modified a record.
-- May all beings be happy.
Message posted via AccessMonster.com LINK
|
|
| |
| | | NetworkTrade |  |
| Posted: Wed Sep 03, 2008 7:32 pm Post subject: RE: Access 2007 when a record is modified, I want to store U |  |
just fyi
User level security remains available in 07 if the database is mdb.
It is the new 07 accdb that does not have user level security.
-- NTC
"unfortune8" wrote:
| Quote: | Now that there aren't user groups and permissions in 2007, how do I store the name of the person that has modified a record. |
|
| |
| | | ErezM via AccessMonster.c |  |
| Posted: Wed Sep 03, 2008 8:15 pm Post subject: Re: Access 2007 when a record is modified, I want to store U |  |
| |  | |
if you're not using code at all, it's a bit hard to use that method, but to finish what i started, if the code i wrote is in a new module, add the field [ModifiedBy] mentioned earlier as a hidden field on every form you need it, and then use the form's BeforeUpdate event write ModifiedBy=fOSUserName
this will set the field ModifiedBy To the current user every time the record is updated
unfortune8 wrote:
| Quote: | Thanks for the response. Unfortunately, I'm not familiar with VB coding or working with modules. I've copied the code you gave into a module, but don't know where to go from there. If you can provide any additional direction, that would be great.
you need to add a ModifiedBy field to every table you need auditing for, and then pick the user name by an entry form that asks for the user name or you [quoted text clipped - 21 lines] Now that there aren't user groups and permissions in 2007, how do I store the name of the person that has modified a record.
|
-- May all beings be happy.
Message posted via AccessMonster.com LINK |
| |
|
|