CurrentUser() function not working

G

Guest

Hi
I have recently upgraded to office 2003 and since doing so, the CurrentUser() function has stopped working in my Access tables - no matter which version - Access 2000, or the converted Access 2003 file, or in new access databases. It does however work in forms!

I have checked the references, and the following are ticked:
Visual Basic for Applications, Microsoft Access 11.0 Object Library, OLE Automation, Microsoft ActiveX Data Objects 2.1 Library, Microsoft DAO 3.6 Object Library.

Any advice on solving the problem would be appreciated
 
B

Brendan Reynolds

No version of Access has ever supported the use of the CurrentUser function
in tables, Andre.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Andre Skeen said:
Hi
I have recently upgraded to office 2003 and since doing so, the
CurrentUser() function has stopped working in my Access tables - no matter
which version - Access 2000, or the converted Access 2003 file, or in new
access databases. It does however work in forms!
I have checked the references, and the following are ticked:
Visual Basic for Applications, Microsoft Access 11.0 Object Library, OLE
Automation, Microsoft ActiveX Data Objects 2.1 Library, Microsoft DAO 3.6
Object Library.
 
G

Guest

Andre,
Most networks have an enviroment variable defined for usernames, so you could do
Environ$("USERNAME")
as the default value, if thats your situation. Run "Cmd" and type "Set" to see whats available. No real security though. I know currentuser is not available now but I feel I used it in the past at some point.
 
D

Douglas J. Steele

Environment variables can be reset very easily, so I don't recommend that
they be used in this situation. If you want the network user id, use the API
call, as shown in http://www.mvps.org/access/api/api0008.htm at "The Access
Web".

However, CurrentUser returns the Access user's name, not the network id. In
other words, it assumes Access Security has been applied, so that each user
has to log into the Access application. (If this isn't the case, it'll
return Admin for every user)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


peter martin said:
Andre,
Most networks have an enviroment variable defined for usernames, so you could do
Environ$("USERNAME")
as the default value, if thats your situation. Run "Cmd" and type "Set"
to see whats available. No real security though. I know currentuser is not
available now but I feel I used it in the past at some point.CurrentUser() function has stopped working in my Access tables - no matter
which version - Access 2000, or the converted Access 2003 file, or in new
access databases. It does however work in forms!Automation, Microsoft ActiveX Data Objects 2.1 Library, Microsoft DAO 3.6
Object Library.
 
B

Brendan Reynolds

Environ$ is one of the functions that is blocked in the new 'sandbox mode'.
Andre may still be able to use it if he's not using Access 2003, or willing
to turn sandbox mode off, but it's something to consider.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


peter martin said:
Andre,
Most networks have an enviroment variable defined for usernames, so you could do
Environ$("USERNAME")
as the default value, if thats your situation. Run "Cmd" and type "Set"
to see whats available. No real security though. I know currentuser is not
available now but I feel I used it in the past at some point.CurrentUser() function has stopped working in my Access tables - no matter
which version - Access 2000, or the converted Access 2003 file, or in new
access databases. It does however work in forms!Automation, Microsoft ActiveX Data Objects 2.1 Library, Microsoft DAO 3.6
Object Library.
 
G

Guest

Thanks for your responses. I am using Access 2003, so I am limited by what it allows.

The short answer then is that CurrentUser is not available for tables, but can be used in forms. The simplest thing for me to do then is to place an invisible field on all my forms, which is easy enough to do. Any other work-around has some limitation or other of it's own. Security is not a major issue for me as yet, but may become so in the future, so I need to take it into account. My database is used by others who may not neccessarily be working from their own machines, so a machine ID/Name wouldn't meet my requirements - a network user might though.

I was using it in Access 2000 tables without a problem, but have found Access 2003 to be much faster over a network and generally superior, so there is no going back.
 
G

Guest

As I am new to this network, I want to first say that I have learned an enormous amount of info from all of you, Thanks very much. . I developed a multiuser database back when we were using Access 2.0. I was able to capture the "user login name" via =Environ$("user") as the default value to a field. Since then, we are now at Windows 2000, and the field DOES NOT recognize this function. I've tried changing it to Environ$("USERNAME") and still no good. . .I've tried the Module of fOSUserName and I can not get that one to work either. . Can someone help. .?

thxs. . . PRTaisho
 
D

Douglas J. Steele

What happens when you try to use fOSUserName? I've never heard of that not
working, regardless of the OS and version of Access.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



PRTaisho said:
As I am new to this network, I want to first say that I have learned an
enormous amount of info from all of you, Thanks very much. . I developed a
multiuser database back when we were using Access 2.0. I was able to
capture the "user login name" via =Environ$("user") as the default value to
a field. Since then, we are now at Windows 2000, and the field DOES NOT
recognize this function. I've tried changing it to Environ$("USERNAME") and
still no good. . .I've tried the Module of fOSUserName and I can not get
that one to work either. . Can someone help. .?
thxs. . . PRTaisho
but can be used in forms. The simplest thing for me to do then is to place
an invisible field on all my forms, which is easy enough to do. Any other
work-around has some limitation or other of it's own. Security is not a
major issue for me as yet, but may become so in the future, so I need to
take it into account. My database is used by others who may not neccessarily
be working from their own machines, so a machine ID/Name wouldn't meet my
requirements - a network user might though.Access 2003 to be much faster over a network and generally superior, so
there is no going back.
 
G

Guest

Actual nothing happens. . Unless I've placed the module at an incorrect property. I've tried at the Default Value and the Control Source of the field. I checked using the CurrentUser() function in the Default Value and it does give me "Admin" as the current user of Access and not the network ID. Sure do appreciate your help. . and thanks again Mr. Steele.. . .
 
D

Douglas J. Steele

You can't set the default value to a table field to the results of
fOSUserName (or to any other user-defined function). You must use a form for
input, and set the default property of the text box on the forn to
fOSUserName.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



PRTaisho said:
Actual nothing happens. . Unless I've placed the module at an incorrect
property. I've tried at the Default Value and the Control Source of the
field. I checked using the CurrentUser() function in the Default Value and
it does give me "Admin" as the current user of Access and not the network
ID. Sure do appreciate your help. . and thanks again Mr. Steele.. . .
 
D

Douglas J. Steele

There's the problem. You can't name the module the same as any function or
routine. Since the function itself is named fOSUserName, you need to name
the module something different.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


PRTaisho said:
Thanks for your patience Mr. Steele. . I am using a form, both in the
previous and present Access version. I created the Module, named it
fOSUserName and then typed that name in the Default Value property of the
text box. I did not mention this and not sure if it has a different effect.
.. My organization is using Windows 2000 operating system with Novell 5
server. Could this be my problem? I believe I've type the syntax correctly
to the module . . .thxs again
 
D

Douglas J. Steele

Take a closer look at http://www.mvps.org/access/api/api0008.htm

It's supposed to be

Dim strUserName As String

not

Dim strUserName As Long

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


PRTaisho said:
Good Morning Mr. Steele. .As your suggestion did work in changing the
module name, however what I am getting back as a result is a "0". . .This is
exactly what I typed in the module. . maybe you can see what's wrong. .?
 
D

Douglas J. Steele

Sorry: it's been too many years since I've worked with Novell to remember
the calls.

See whether http://www.mvps.org/access/api/api0066.htm works with Novell.
(make sure you copy it correctly this time! <g>)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



PRTaisho said:
Mr Steele. . .u r the man. . . ! One last thing (on this subject at
least). . .what part of the syntax can I rewrite or change to give me the
"user" name vs the "user" Hash ID. . ? Both are identified on the Novel 5
server. Thxs again for all your help.
 

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