Solved

Do DNS/NetBIOS resolution using VBA

Posted on 2013-10-24
2
798 Views
Last Modified: 2013-10-24
Using this MS code as a base I'm able to build


Public Function TestPing()

Dim SQL As String
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim I As Long


Dim hostname$, HostLen&
HostLen& = 256
hostname$ = Space$(HostLen&)


Dim Reply As ICMP_ECHO_REPLY
Dim lngSuccess As Long
Dim strIPAddress As String
   
I = 1
   'Get the sockets ready.
If SocketsInitialize() = True Then
      
    
    SQL = "SELECT ServerName, IP_Address, Ping_Status " & _
        "FROM Server_List " 
        
    Set DB = CurrentDb()
    Set RS = DB.OpenRecordset(SQL)
    
    If RS.EOF = False Then
        RS.MoveFirst
        Do Until RS.EOF = True
            strIPAddress = RS!IP_Address
            
            lngSuccess = ping(strIPAddress, Reply)
            With RS
                .Edit
                !Ping_Status = EvaluatePingResponse(lngSuccess)
                .Update
            End With
            
            Debug.Print I & ": " & "Address to Ping: " & strIPAddress & ": " & EvaluatePingResponse(lngSuccess)
            I = I + 1
            RS.MoveNext
        Loop
    End If
    
    RS.Close

    Set RS = Nothing
    Set DB = Nothing
      
    'Clean up the sockets.
    SocketsCleanup
      
Else
   
   'Winsock error failure, initializing the sockets.
   Debug.Print WINSOCK_ERROR
   
End If

End Function

Open in new window


So now what I want to do is verify the name that is currently attached to that IP address. So I am looking at the code linked at the bottom of the first set of code. But from what I can tell that only gets the current machine, not the name of a machine from the IP address. I want to build my code so that I close the first recordset and then process something like this:

   
    SQL = "SELECT ServerName, IP_Address, Ping_Status, Ping_ServerName " & _
        "FROM Server_List " & _
        "WHERE Server_List.Ping_Status = 'Success!'"
        
    Set RS = DB.OpenRecordset(SQL)
    
    If RS.EOF = False Then
        RS.MoveFirst
        Do Until RS.EOF = True
        
       IPAddr = RSIP_Address
--------------------------------------------------------------------
       'Get remote name from the IP address function  here.
        MachName = blah
--------------------------------------------------------------------
         With RS
                .Edit
                !Ping_ServerName = MachName 
                .Update
           End With
           RS.MoveNext
        Loop
    End If

Open in new window


The list I'm starting with includes IP addresses that were re-used on other servers. So I want to verify what the current machine is so I can then see if I have to dig into them.

Thanks.
0
Comment
Question by:Jim P.
2 Comments
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 39597807
Use the code described here: http://access.mvps.org/access/api/api0067.htm
0
 
LVL 38

Author Closing Comment

by:Jim P.
ID: 39598349
That worked. Just couldn't find a good google for it.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now