By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

How do I display Windows Username in Form/Table?

P: 10
I have copied the code found at http://www.mvps.org/access/api/api0008.htm into a module and saved the module as fOSUserName.

Following the directions listed in a similar post (http://bytes.com/topic/access/answer...nto-form-field), I then created a field on my table labeled "UserID" and inserted the field into the related form. I set the default value for the text box in the form to =fOSUserName(), but #Name? is still displayed in the text box when I switch to form view.

Any help would be great!
Feb 16 '12 #1

✓ answered by Rabbit

There's going to be a naming conflict if you give the module the same name as the function.

Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,365
There's going to be a naming conflict if you give the module the same name as the function.
Feb 16 '12 #2

NeoPa
Expert Mod 15k+
P: 31,487
It seems this is less about the actual code in the module and more about referencing that code, but first I would suggest that you check the code works from the Immediate pane of the VBA IDE window (Debugging in VBA). If it's not working for any reason then we have our own article thread on this at Function to Return UserName (NT Login) of Current User. They're probably very similar I expect.

Anyway, if a reference to a Public function in a standard module (I'm assuming that's what you have) isn't working as a DefaultValue for a control on your form, then I'm not sure what is going on. I would expect it to. What version of Access are you using?
Feb 16 '12 #3

P: 10
Rabbit,

Thanks for the help! I simply renamed the module and it works. You have no idea how much this help out! My headache has miraculously disappeared.

Thanks to you, as well, NeoPa.
Feb 16 '12 #4

NeoPa
Expert Mod 15k+
P: 31,487
Nice catch there by Rabbit :-)

You may want to select the button marked "Best Answer" by post #2.
Feb 16 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.