API Get Login Name

  • Thread starter cableguy47905 via AccessMonster.com
  • Start date
C

cableguy47905 via AccessMonster.com

I was using Environ$("Username") to use to automatically fill in for the
User_ID on my forms.
When Access opens it will always ask two questions dealing with security. I
accidentally answered the first one as yes. I can not get it to come back up,
and I don't even know what the question was, but I think it was dealing with
macros or unsafe expressions. Anyhow, now my User_ID field comes up as Name?

I tried to implement the function referred to on the Access page, by Dev
Ashish. I am not sure how to implement it though. I have copied it into a
new module, and then how do I call it up?

I have checked to see if Username is still set on DOS, and it is. When I use
Environ$("Username") in the immediate window in VBA, it comes up with the
correct ID. I am not sure why it is not working. Can anyone help with this?

Thanks,
Lee
 
D

Duane Hookom

I would never trust Environ(). The API would be used in the same way that
you used Environ(). You can set the default value of a text box on a form
to:

=fOSUserName()

Make sure the module is not saved with the same name as the function.
 
C

cableguy47905 via AccessMonster.com

Great! Thanks Duane. I was putting the variable name in the function, I
knew better than that.

Now, in the SQL of a query, If I set
WHERE EDS_ID = fOSUserName()

I keep getting function undefined in expression.

How can I use it as criteria for the query?

Thanks,

Lee

Duane said:
I would never trust Environ(). The API would be used in the same way that
you used Environ(). You can set the default value of a text box on a form
to:

=fOSUserName()

Make sure the module is not saved with the same name as the function.
I was using Environ$("Username") to use to automatically fill in for the
User_ID on my forms.
[quoted text clipped - 20 lines]
Thanks,
Lee
 
C

cableguy47905 via AccessMonster.com

Thanks again,

I thought it was fixed, but after going to a new record again, I still get
#Name?
I did set the default to fOSUserName(), but I am still getting #Name? in the
txtbox.
Do I need a certain reference?


Duane said:
I would never trust Environ(). The API would be used in the same way that
you used Environ(). You can set the default value of a text box on a form
to:

=fOSUserName()

Make sure the module is not saved with the same name as the function.
I was using Environ$("Username") to use to automatically fill in for the
User_ID on my forms.
[quoted text clipped - 20 lines]
Thanks,
Lee
 
D

Duane Hookom

Did you include the "="?

--
Duane Hookom
MS Access MVP

cableguy47905 via AccessMonster.com said:
Thanks again,

I thought it was fixed, but after going to a new record again, I still get
#Name?
I did set the default to fOSUserName(), but I am still getting #Name? in
the
txtbox.
Do I need a certain reference?


Duane said:
I would never trust Environ(). The API would be used in the same way that
you used Environ(). You can set the default value of a text box on a form
to:

=fOSUserName()

Make sure the module is not saved with the same name as the function.
I was using Environ$("Username") to use to automatically fill in for the
User_ID on my forms.
[quoted text clipped - 20 lines]
Thanks,
Lee
 
D

Duane Hookom

Does the function work anywhere? What do you get if you open the immediate
window (press Ctrl+G) and enter:

? fOSUserName()


--
Duane Hookom
MS Access MVP

cableguy47905 via AccessMonster.com said:
Yeah
Default value =fOSUserName()

In the query it says that the function is not defined.


Duane said:
Did you include the "="?
Thanks again,
[quoted text clipped - 18 lines]
Thanks,
Lee
 
C

cableguy47905 via AccessMonster.com

After doing that, I got the error:

Compile Error:
Expect variable or procedure, module

But I checked out the help for that error and found that I had name the
module the same as the procedure. So, I changed the name of the module. It
works now.

Thank you, I didn't think of checking the immediate window for that procedure,
I checked it for the Environ() function, but didn't think to check it for
this one.

I appreciate your help.

Lee

Duane said:
Does the function work anywhere? What do you get if you open the immediate
window (press Ctrl+G) and enter:

? fOSUserName()
Yeah
Default value =fOSUserName()
[quoted text clipped - 8 lines]
 
D

Duane Hookom

From my very first reply:
"Make sure the module is not saved with the same name as the function."

Glad to hear you got this working.
--
Duane Hookom
MS Access MVP

cableguy47905 via AccessMonster.com said:
After doing that, I got the error:

Compile Error:
Expect variable or procedure, module

But I checked out the help for that error and found that I had name the
module the same as the procedure. So, I changed the name of the module.
It
works now.

Thank you, I didn't think of checking the immediate window for that
procedure,
I checked it for the Environ() function, but didn't think to check it for
this one.

I appreciate your help.

Lee

Duane said:
Does the function work anywhere? What do you get if you open the immediate
window (press Ctrl+G) and enter:

? fOSUserName()
Yeah
Default value =fOSUserName()
[quoted text clipped - 8 lines]
Thanks,
Lee
 

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