How can I derive the username (programmatically) after a user log.

G

Guest

I am using MS Access security features to enable users to log into the
database. During the operation, I need to know who is the person (username)
that has logged in. Is there a function that will give this information?
 
J

Jack MacDonald

currentuser()

I am using MS Access security features to enable users to log into the
database. During the operation, I need to know who is the person (username)
that has logged in. Is there a function that will give this information?


**********************
(e-mail address removed)
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
 
T

T. W.

Hello all,
I'm having a slight problem. I've applied Access security to an MDB
file (using the workgroup file), and it works fine.
I did this to track which user adds a record to certain tables. I have
two other fields in the same table with a default value of Time() and Date()
which both give the current time and date of the record being created or
updated. I added the third field with a default value of CurrentUser() but
it gives the below error message.

Unknown function 'CurrentUser' in validation expression or default value on
(gives the table.field name).

Does anyone know what's going on? The database is in Access 2000 file
format and I'm using Access 2003.
 
R

Rick B

did you put =currentuser()
?

T. W. said:
Hello all,
I'm having a slight problem. I've applied Access security to an MDB
file (using the workgroup file), and it works fine.
I did this to track which user adds a record to certain tables. I have
two other fields in the same table with a default value of Time() and Date()
which both give the current time and date of the record being created or
updated. I added the third field with a default value of CurrentUser() but
it gives the below error message.

Unknown function 'CurrentUser' in validation expression or default value on
(gives the table.field name).

Does anyone know what's going on? The database is in Access 2000 file
format and I'm using Access 2003.
 
T

Todd Shillam

T. W. said:
Hello all,
I'm having a slight problem. I've applied Access security to an
MDB file (using the workgroup file), and it works fine.
I did this to track which user adds a record to certain tables. I
have two other fields in the same table with a default value of
Time() and Date() which both give the current time and date of the
record being created or updated. I added the third field with a
default value of CurrentUser() but it gives the below error message.

Unknown function 'CurrentUser' in validation expression or default
value on (gives the table.field name).

Does anyone know what's going on? The database is in Access 2000 file
format and I'm using Access 2003.

If you just want to capture whomever is logged onto the computer in a
Windows network, just set the default value to the system's %USERNAME%
environmental variable. Here's what the default should look like:

=Environ$("UserName")

Simple, and it works.

Todd
 
T

Todd Shillam

Todd Shillam said:
If you just want to capture whomever is logged onto the computer in a
Windows network, just set the default value to the system's %USERNAME%
environmental variable. Here's what the default should look like:

=Environ$("UserName")

Simple, and it works.

I should also add that if you would like to see what other system
environmental variables you may use, just open MS-DOS:

START>Run>Type 'cmd' and press the {Enter} key--this will open a
command-line window.

When the window opens, just type 'set' and press the {Enter} key--a list
will appear that displays all your environmental variables. You can use
these system variables in your Access programs like I demonstrated in
another post above.

Best regards,

Todd
 
T

T. W.

It told me that Environ$ was an unknown function.

Let me clarify, that I'm trying to put this into the Default Value property
field of the table itself, and not in the form. I would love to get the
Windows username over the Access username.
 
T

T. W.

I put that, same error.

I think that the confusion here is that I'm trying to put this into the
Default Value property field of the table itself. I'm not putting this in a
text box on a form. The CurrentUser() works on the form, but I need to be
able to make the text box invisible, and since the form (its a subform) is
in datasheet view, it won't stay invisible.
 
T

Todd Shillam

I double checked the code, make sure you copy this exactly (don't change
anything) and paste it into the 'Default Value' block in table design:

=Environ$("UserName")

Todd
 
T

Todd Shillam

Douglas,

When you state "trivial to reset", what are you saying? Would you elaborate?
Thank you.

Best regards,

Todd Shillam
 
T

T. W.

I'm not certain what you mean that something even needs resetting, but the
problem I have with the link provided before is that my VBA skills are not
there. I don't know how to put the code (or change it for my purposes) into
the VBA workspace (assuming that's where it goes).

I need directions on doing that.
 
T

Todd Shillam

Ok, before we go any further, lets make sure some things are clear:

1. What operating system are you running? Windows 2000, Windows XP?

2. What version of Microsoft Access?

Thanks,

Todd

T. W. said:
I'm not certain what you mean that something even needs resetting, but the
problem I have with the link provided before is that my VBA skills are not
there. I don't know how to put the code (or change it for my purposes)
into the VBA workspace (assuming that's where it goes).

I need directions on doing that.

<snip>
 
T

Todd Shillam

Douglas,

Thank you very much--I now see the error in my way. I'll be sure to use the
GetUserName API.

Best regards,

Todd Shillam
 

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