Currentuser () as default value in table?

  • Thread starter Thread starter Douglas J. Steele
  • Start date Start date
D

Douglas J. Steele

AFAIK, you can't. You can, however, make it the default for a form field
bound to a field in the table.
 
Hi Henro,

It can't be done in an Access table. Instead, ensure that all data entry
is done via a form, and set the default values there.
 
You can only use SQL or VBA expressions for the default value.

CurrentUser is a method of the Application Object,
so you can't use that.

However, you can use

=Environ("UserName")

as a default value.
Environ is a VBA inbuilt function. You can also use
Command(), CurDir() etc. You may even be able to
work out how to use SetOption to set the 'command line
argument' option in Access. These VBA default values
don't work exactly like SQL default values: if you open
a derived query you won't see the default value until
you start typing in the new record.

To see the environment variables on your PC, open a DOS or
CMD prompt window and type SET.

If your environment does not have a "UserName" set, or if
you wish to use your own value, you may be able to set an
environment value by using a Win API or a Shell object.

This is not a secure method, because users generally are
able to change the environment options.

(david)
 
Use a form, and make it the default value for the textbox you use to
display the field.
 
Hi Henro,

It can't be done. Instead, do your data entry via a form with a textbox
bound to the field, and set the textbox's Default Value to
=CurrentUser()
 
I am trying to make CurrentUser () the default value for a TEXTfield in a
table. How can I do this?

TIA HENRO
 
Back
Top