Solved

Do DNS/NetBIOS resolution using VBA

Posted on 2013-10-24
2
782 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

919 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

12 Experts available now in Live!

Get 1:1 Help Now