Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How do I get the Computer Name from within VBA
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jonathan  
View profile  
 More options Jan 25, 6:44 pm
Newsgroups: microsoft.public.vb.syntax
From: Jonathan <Jonat...@discussions.microsoft.com>
Date: Sun, 25 Jan 2009 15:44:00 -0800
Subject: How do I get the Computer Name from within VBA
I am writing an Access database (Access 2003 on WinXP and VISTA) in VBA and I
would like to be able to read out the computer name of the PC the database is
going to be running on.
Is there a way to do this?

Thanks


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Serflaten  
View profile  
 More options Jan 25, 8:59 pm
Newsgroups: microsoft.public.vb.syntax
From: "Larry Serflaten" <serfla...@usinternet.com>
Date: Sun, 25 Jan 2009 19:59:11 -0600
Local: Sun, Jan 25 2009 8:59 pm
Subject: Re: How do I get the Computer Name from within VBA

"Jonathan" <Jonat...@discussions.microsoft.com> wrote

> I am writing an Access database (Access 2003 on WinXP and VISTA) in VBA and I
> would like to be able to read out the computer name of the PC the database is
> going to be running on.
> Is there a way to do this?

One easy way is to use enviroment settings.  For a complete list try this:

  For i = 1 To 50
    Debug.Print i, Environ(i)
  Next

Specifically, for the computer name, try this:

MsgBox Environ("COMPUTERNAME")

Just be aware that these settings can be changed by the user, but for the most
part, are usually accurate....

HTH
LFS


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan  
View profile  
 More options Jan 26, 2:47 pm
Newsgroups: microsoft.public.vb.syntax
From: Jonathan <Jonat...@discussions.microsoft.com>
Date: Mon, 26 Jan 2009 11:47:28 -0800
Local: Mon, Jan 26 2009 2:47 pm
Subject: Re: How do I get the Computer Name from within VBA
Dear Larry,
Thanks! - That's it - I don't know why I never came across this function.
Solved my problem in seconds.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl E. Peterson  
View profile  
 More options Jan 26, 6:21 pm
Newsgroups: microsoft.public.vb.syntax
From: "Karl E. Peterson" <k...@mvps.org>
Date: Mon, 26 Jan 2009 15:21:23 -0800
Local: Mon, Jan 26 2009 6:21 pm
Subject: Re: How do I get the Computer Name from within VBA

Jonathan wrote:
> I am writing an Access database (Access 2003 on WinXP and VISTA) in VBA and I
> would like to be able to read out the computer name of the PC the database is
> going to be running on. Is there a way to do this?

Here's another way that no user can muck up...

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

   Private Function CurrentMachineName() As String
      Dim Buffer As String
      Dim nLen As Long
      Const CNLEN As Long = 15  ' Maximum computer name length
      Buffer = Space$(CNLEN + 1)
      nLen = Len(Buffer)
      If GetComputerName(Buffer, nLen) Then
         CurrentMachineName = Left$(Buffer, nLen)
      End If
   End Function

--
.NET: It's About Trust!
 http://vfred.mvps.org


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google