I keep getting an "Unknown function "CurrentUser()" error

G

Guest

I am trying to design a table that has the current database user defaulted
and validated in a "UserName" field. But, when I put the "=CurrentUser()"
expression in the Default Value or Validation Rule I get an error when I save
the table that says "Unknown function 'CurrentUser()' in Validation
expression or Default Value on Tablename.fieldname".

I tried implementing this validation on the form level, but when I do that,
the username is defaulted in the form and after I submit the record, I check
the record on the table and the username will actually show up, but as I am
looking at it, a couple of seconds later it will disappear! Please Help.
Thank you.
 
R

Rick Brandt

Jason said:
I am trying to design a table that has the current database user
defaulted and validated in a "UserName" field. But, when I put the
"=CurrentUser()" expression in the Default Value or Validation Rule I
get an error when I save the table that says "Unknown function
'CurrentUser()' in Validation expression or Default Value on
Tablename.fieldname".

I tried implementing this validation on the form level, but when I do
that, the username is defaulted in the form and after I submit the
record, I check the record on the table and the username will
actually show up, but as I am looking at it, a couple of seconds
later it will disappear! Please Help. Thank you.

Only Jet functions can be used as defaults in a table definition. Not
Access/VBA functions or user defined functions. This is because the default
has to be honored even if the table is edited from another program and
Access/VBA is not involved.

I guess CurrentUser() falls into the Access/VBA category because I did
confirm your results.
 
G

Guest

Thank you Rick. I understand now why I can't use the CurrentUser() in the
table definition, but what about in the form view? The form is the faceplate
(Access/VBA part) and if the form has a default value, that should be
separate from the table default value correct? I'm confused as to why the
value shows up in the table and then disappears. I thought there was a
disconnect in a sense between the table and the form.
 
G

Guest

Thank you Rick. I understand now why I can't use the CurrentUser() in the
table definition, but what about in the form view? The form is the faceplate
(Access/VBA part) and if the form has a default value, that should be
separate from the table default value correct? I'm confused as to why the
value shows up in the table and then disappears. I thought there was a
disconnect in a sense between the table and the form.
 
R

Rick Brandt

Jason said:
Thank you Rick. I understand now why I can't use the CurrentUser()
in the table definition, but what about in the form view? The form
is the faceplate (Access/VBA part) and if the form has a default
value, that should be separate from the table default value correct?
I'm confused as to why the value shows up in the table and then
disappears. I thought there was a disconnect in a sense between the
table and the form.

Used in the form it should work. I know of no mechanism that would make a value
appear in the table one minute and then somehow "vanish".

Are you using Access user-level security? If not, CurrentUser() will always
return the same value anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top