Solved

Do DNS/NetBIOS resolution using VBA

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

685 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