Solved

Do DNS/NetBIOS resolution using VBA

Posted on 2013-10-24
2
872 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.
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

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

Industry Leaders: 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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

623 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