Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 10th, 2005, 10:14 AM
Registered User
Join Date: Apr 2005
Location: El Paso, TX, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieve Computer Name Programatically

Is there anyone out there who can tell me how to retrieve the name of the computer in use programmatically using VBA?
Reply With Quote
  #2 (permalink)  
Old April 10th, 2005, 12:25 PM
Friend of Wrox
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post

In a Windows environment the easiest way is:

  ComputerName = VBA.Environ("ComputerName")

If that doesn't give you what you want you can use an API:

  Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
                        (ByVal lpBuffer As String, nSize As Long) As Long

Go to http://msdn.microsoft.com and search for "GetComputerName" for details about this.

Or you can use the Windows script host:

  Include a Reference to: "Window Script Host Object Model" (file C:\WINDOWS\system32\wshom.ocx) and do the following:

  Dim objSH As New IWshRuntimeLibrary.WshNetwork
  ComputerName = objSH.ComputerName

While Windows systems should all have the wshom.ocx file, adding this Reference can make your application vulnerable to having a "MISSING" reference.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
Reply With Quote
  #3 (permalink)  
Old April 10th, 2005, 03:51 PM
Registered User
Join Date: Apr 2005
Location: El Paso, TX, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Worked Perfecly! Thanks A "Million" to Randall J Weers

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Programatically xlr8 BOOK: Beginning C# 2005 Databases 1 April 30th, 2007 08:56 AM
how to register Com components programatically vinaykumar_inavolu C# 2005 0 October 12th, 2006 07:19 AM
MaxDataAxisValue programatically ganans Crystal Reports 0 May 6th, 2006 06:30 PM
Using data programatically jasongorringe ASP.NET 2.0 Basics 1 February 10th, 2006 02:42 PM
How Do I Manipulate Graph Programatically sg48 Access VBA 11 June 24th, 2004 08:40 PM

All times are GMT -4. The time now is 03:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.