Getting the Computer Name

S

Stuart B

I have found the following link to code to get the computer name from within
an Access VBA code module.
http://www.mvps.org/access/api/api0009.htm
unfortunately I cannot seem to get it work.

It looks as if it is because of the two Functions with there being no end
function on the first. Adding an
End Function
after the first Private Declare Function... statement then raises an error
on the "lib" keyword.

Is there anyone who can advise me?

Many thanks,

Michael.
 
D

DebbieG

You do not need an End Function for the Private Declare Function.


"Stuart B" <SHB> wrote in message |I have found the following link to code to get the computer name from within
| an Access VBA code module.
| http://www.mvps.org/access/api/api0009.htm
| unfortunately I cannot seem to get it work.
|
| It looks as if it is because of the two Functions with there being no end
| function on the first. Adding an
| End Function
| after the first Private Declare Function... statement then raises an error
| on the "lib" keyword.
|
| Is there anyone who can advise me?
|
| Many thanks,
|
| Michael.
|
|
 
D

DebbieG

Did you put the code in a module (Insert, Module)? The Private Declare has to be before any Function or Sub.

You don't say what you want to do with the computer name once you know what it is, but then you can use fOSMachineName in any form
if that is what you're wanting to.

HTH,
Debbie


"Stuart B" <SHB> wrote in message |I have found the following link to code to get the computer name from within
| an Access VBA code module.
| http://www.mvps.org/access/api/api0009.htm
| unfortunately I cannot seem to get it work.
|
| It looks as if it is because of the two Functions with there being no end
| function on the first. Adding an
| End Function
| after the first Private Declare Function... statement then raises an error
| on the "lib" keyword.
|
| Is there anyone who can advise me?
|
| Many thanks,
|
| Michael.
|
|
 
A

Arvin Meyer

Hi Stuart,

That code was written sometime ago in Access 97. I just checked it in Access
2000 on a Windows 2000 Professional machine and a Windows XP machine using
Access 2002. It works perfectly on both. What error are you getting?

BTW, I'm a webmaster of that site so I can fix errors if and when they are
found.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
S

Stuart B

Many thanks Debbie,

The key was to place the Private Declare at the begining of the module.

All the best,

Stuart.
 

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