Hi, JJ.
I have created a function, =user(), that captures the user's log in name. I
would like to have this set as a "default value" in the table whenever a new
record is added. I created a field in the table and placed the function,
=user(), in the table, and Access does not recognize it.
That's a table-level constraint, and table-level constraints must use
built-in functions. The common solution is to create a form and set the
bound text box control's Default Value Property to the function name.
However, since you are using a Reserved Word for your function name, you'll
have difficulties. Change the function name to something like getUser() and
make it a public function in a standard module, so that any form can retrieve
this value.
To set the Default Value Property of the text box, open the form in Design
View, open the Properties dialog window, and then select the text box bound
to the field for the user name. Select the Data tab and type the following
in the Default Value Property:
=getUser()
(Use your new function name.) Ensure that there are no spaces and that the
equals sign precedes the name of the function and a pair of open and closed
parentheses follow the name of the function. Save the form and close it.
Now whenever a new record is created with this form, the user's login name
will be assigned to the bound field for this text box.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.