Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / April 2008

Tip: Looking for answers? Try searching our database.

Determing who added a record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 12 Apr 2008 01:29 GMT
Access 2003

I have in the past, included the following as the default value in a field
"AddedBy" to determine who has entered a new record:

=Environ("username")

This seems not to work on Access 2007 (or Vista - I forget which).

So what would be the proper way to "CODE" this as a module and use it more
readily and without version issues.

tia
Dave
Arvin Meyer [MVP] - 12 Apr 2008 02:54 GMT
> Access 2003
>
[quoted text clipped - 7 lines]
> So what would be the proper way to "CODE" this as a module and use it more
> readily and without version issues.

This code has been tested and works in both Vista and Access 2007

http://www.mvps.org/access/api/api0008.htm

Save the code and api in a module with a name other than the function's
name. You can then use the name of the function as a query criteria, or in
the AddedBy field like:

=fOSUserName()
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

aaron_kempf@hotmail.com - 12 Apr 2008 03:58 GMT
wow that is funny.

Do you even realize that this is built into SQL Server?

select suser_sname() as thisUser

that's all you got to do to get to this info in SQL Server.
Wouldn't it be nice if things 'just worked' out of the box??

-Aaron

> > Access 2003
>
[quoted text clipped - 19 lines]
> --
> Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com
Dave - 12 Apr 2008 04:43 GMT
Aaron,

I am not sure if you are making fun of my ignorance here or I am too dumb to
use the information you provided but I don't understand how this helps me.

Thanks for the reply,

dave

> wow that is funny.
>
[quoted text clipped - 34 lines]
>> Arvin Meyer, MCP,
>> MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com
Arvin Meyer [MVP] - 12 Apr 2008 06:17 GMT
> Aaron,
>
[quoted text clipped - 3 lines]
>
> Thanks for the reply,

Dave,

His information is not designed to help you. Aaron is what is known in the
newsgroups as a troll. He wanders around looking for arguments. He thinks
he's smarter than everyone, but contantly proves otherwise. I have him
blocked so the only time I see his inane remarks is when he's quoted in
someone else's reply.

Aaron threatened one of the Microsoft MVPs (Tom Wickerath) and this was the
result:

On Saturday, June 30, 2007, Aaron was taken down by the Tacoma Police Dept.
SWAT Team after earlier making public threats to Tom's safety in the
newsgroups.
He ended up pleading guilty to the crime of cyberstalking, which the
Prosecutor later decided to pursue as a misdemeanor instead of a felony. On
Dec. 7, 2007, the judge handed down the following sentence:

1.)  Pay $500 court costs
2.)  24 months probation
3.)  He must use his name in any electronic postings
     --no aliases allowed.
4.)  Complete an anger management session.
5.)  Perform 136 hours of community service.

It looks to me as if the anger management session hasn't been started yet.
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Dave - 12 Apr 2008 04:22 GMT
Arvin,

Thanks for the link.
I am however having some trouble using it.

I crerated a Module called "UserName"

I pasted in the code exactly as it was in the link.

I then tried both of these as default value:

=fOSUserName()

=UserName()

Both gave me errors.

Should this be public and not private?
Or am I missing/not doing something else wrong?

Dave

>> Access 2003
>>
[quoted text clipped - 17 lines]
>
> =fOSUserName()
Arvin Meyer [MVP] - 12 Apr 2008 06:04 GMT
> Arvin,
>
[quoted text clipped - 15 lines]
> Should this be public and not private?
> Or am I missing/not doing something else wrong?

Not sure what the problem is. Have you copied the api code? Have you
compiled the code? Does it compile? If not, what is the error message? If it
does compile try running something like this in a query;

SELECT FirstName, LastName, fOSUserName() AS Expr1
FROM MyTable;

Of course you'll need to put your own field and table names in.

One other thing that occured to me, you cannot use non-built-in functions in
a table because the expression service doesn't run in tables. But it should
work in a query, form, or report.
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Dave - 12 Apr 2008 16:05 GMT
"Have you copied the api code? Have you
compiled the code? Does it compile? "

Well I am totally missing something.
I copied the code that was one the link you posted into a new module.
I am not sure what the api code is but I am sure I have compiled nothing.
sounds like this is going to be above my head for what I was hoping was
simple :(

Thanks for the tip about aaron

dave

>> Arvin,
>>
[quoted text clipped - 28 lines]
> in a table because the expression service doesn't run in tables. But it
> should work in a query, form, or report.
Pete D. - 12 Apr 2008 21:07 GMT
I have used this for years in the form before update.  I also display it on
the form, tends to make users more aware of attention to details.  Also when
I had to go to a hearing I had to place individual at the machine, not just
someone used thier logon so with witness that they were at that machine case
closed.  fOSMachineName is also on same web site.  Much thanks to Dev Ashish
for fOSUserName and fOSMachineName.

'------------------------------------------------------------
' M_LastModified
'
'------------------------------------------------------------
Function fLastModified()
On Error GoTo fLastModified_Err
   With CodeContextObject
       .DateModified = Date
       .TimeModified = Time()
       .UserLogon = fOSUserName()
       .MachineName = fOSMachineName()
   End With
fLastModified_Exit:
   Exit Function
fLastModified_Err:
   MsgBox Error$
   Resume fLastModified_Exit
End Function

>> Arvin,
>>
[quoted text clipped - 28 lines]
> in a table because the expression service doesn't run in tables. But it
> should work in a query, form, or report.
John W. Vinson - 12 Apr 2008 06:10 GMT
>Should this be public and not private?

Yes.
Signature


            John W. Vinson [MVP]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.