Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Current user populating a table 1

Status
Not open for further replies.

Willie78

Technical User
Jun 4, 2004
67
GB
Hi all

I have a quick question.... I would like the currentuser to populate a filed in a table. I have tried using the =currentuser() function without effect. If i add it on a form then it defaults the whole table to that user. I would like the current user to be recorded against each record

Does any one have any ideas how i can do this???

Cheers

Paul
 
'I would like the current user to be recorded against each record'

When? When the record is created? Use the default value property? Some other time - please explain when...

 
I need the user name to be populated at record creation... the currentuser() function can't be used as a default value in the table... I hadn't thought of using the default value in the form.... Thanks

Paul W
 
This all assumes you have implemented Access security. Otherwise CurrentUser() will return "Admin".

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
You can add a code module that will get the Windows ID:

Function GetUserID()
GetUserID = Environ("Username")
End Function

Then in the form control's default, put =GetUserID()

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
I would not rely on Environ("User") across all PCs and operating systems. I prefer the code at which returns the logged in user name.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi Duane--Good put. I've used that before too. Current company = all Windows. Now that I've had to "wrap" the function to get thru the Sandboxmode storm, it's easy enough for me to change whenever I need to.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
To dhookom

Many thanks for this info
I have created the module. How do I use this in a form

Ken
 
In a form control (like a text box), make the control source be

=GetUserID()

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top