Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Adding Machine User into form

Status
Not open for further replies.

gustavvs

IS-IT--Management
May 19, 2004
13
0
0
US
This should be something simple:

To expand on
I try running the recommended function ( within my form however I keep getting a #Name? error. I'm setting the Control Source of the field to the function (fOSUserName). I'm not passing any parameters. The function is saved as a module.

I tried to run it in query and an error message of unregonized function comes up.

I'm trying to do a test to see when a user accesses the form, the user account will appear on the form and then be saved to a table when they either exit or save.
 
Hi
I have tried this as the Control Source of a text box:
[tt]=fOSUserName()[/tt]
And it works fine, though I get a #Name? error if I leave out the brackets. [ponder]
 
This could be a "scope" issue.

From the database window, use the keys CTRL-G to open up the VBA coding window and the immediate / debugger window. In the debugger window, type

? fOSUserName()


If you get an error...
Compile error
Sub or function not defined
... then you either have a spelling mistake in a name, or Access can not find the function.

As per Dev Ashish, this code is created in a module. From the menu, "Tools" -> "Database Objects" -> "Modules". If you can not find a module in this location, create one and paste the code as given in the link.

Richard
 
Thanks for the replies.

I am still having problems. I had previously ran the code in a Module without success. But I created a Module and copied the code over. I ran in debug and got a compile error, Expected Variable or procedure, not Module.

I entered the Module Name with () and still get an error #Name?.

Any other ideas? I can't post the code (per developer request in the code).

Thank you very much,
Peter
 
Change the name of the module (should not be the same as any function or sub name)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well I discovered one problem. I was missing advapi32.dll. Now that is loaded I'm receiving a whole new compile error.
"Expected:line number or label or statement or end of statement" when I try to run it in debug and I still get the #Name? when I ran it in form.

Now I put a watch on it and step through the code. Of course, it ran without a problem and it even picked up the network name (thou dropping it at the end of the function).

Does it sound like a code problem or a messed up machine or a screwed up programmer? :)I might try the code at home to see if it works there.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top