View Full Version : auto populate user id


dkirk02
06-11-2001, 10:40 AM
I have a multiuser database on our WAN here at work. I am wondering if anyone could help me out on autopopulating the user id on a form, thus writing it to the table. I have heard that this can be done when you have a user work group in place, but the example db that I have to go by gives no indication in the field properties or in the code that would explain how this is done. In the old db, the field is simply an unbound control with no table/field referenced in the control source.
Any thoughts?

Matthew Snook
06-11-2001, 12:42 PM
From Access help:

CurrentUser Method


You can use the CurrentUser method to return the name of the current user of the database.

For example, use the CurrentUser method in a procedure that keeps track of the users who modify the database.

Syntax

CurrentUser

Remarks

The CurrentUser method returns a string that contains the name of the current user account.

If you haven't established a secure workgroup, the CurrentUser method returns the name of the default user account, Admin. The Admin user account gives the user full permissions to all database objects.

If you have enabled workgroup security, then the CurrentUser method returns the name of the current user account. For user accounts other than Admin, you can specify permissions that restrict the users' access to database objects.

The following example obtains the name of the current user and displays it in a dialog box.

MsgBox("The current user is: " & CurrentUser)...


I tried it, works well. Just create an unbound text box, and put

=[CurrentUser]

into the "Default Value" slot in properties. Voila, or whatever.

Matt

dkirk02
06-12-2001, 10:49 AM
Thanks, that worked like a charm!