The answer depends on what you want to do. If you want the computer name to appear in a text box on a form place the following in the Control Source of the text box.
=fOSMachineName()
If you want to use it in a query just place something like the following in the Field Name cell of the query designer.
CompName: fOSMachineName()
You can use it as criteria in a query.
Select * From UserTbl
Where CompName = fOSMachineName()
You can use it to update a table.
Update tbl Set CompName = fOSMachineName()
Where UserID=5
You can use it in VBA code.
If fOSMachineName()='chyld' Then
<do some stuff>
Else
<do different stuff>
End If
Let me know if you have further questions. Terry Broadbent
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
Thanks again, only problem is now I have copied and pasted the contents of the module you pointed me to, but when I change the control source to the '=fOSMachineName()' in the text box in normal mode I just see '?Name'!
No, I set the control source of the text box to the following:
=fOSMachineName()
As Terry B instructed in an earlier example, it didn't work though.... BOO HOO.
If you could help it would be much appreciated.
Please understand that I am a true beginner in all this and really don't know a lot about VB Programming or SQL etc. Everything I know is self tought...
Examine the control source for the text box and make sure the entry has no [] or " around it. It must read exactly
=fOSMachineName()
The () must be included.
Which version of Access are you running? Terry Broadbent
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
Open the module with the function in it. Open the immediate Window. Select View | Immediate Window from the menu. Type
?fOSMachineName()
and press enter. You should see the name of your computer. If you don't, place a breakpoint in the code by clicking on the line that reads "lngLen = 16" and pressing F9.
Go back to the immediate window and run the function again. Use F8 to step through the code one line at a time. Hover the mouse pointer over each variable name to check the value after each step. See if the function and API calls are actually working. Terry Broadbent
"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
I don't suppose there is any other way of doing it without the code stuff. I don't understand a single word of what you said there Terry, but thanks for all your help anyway!! LOL
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.