Display an indicator if computer is connected to a network (1 Viewer)

duke217

Registered User.
Local time
Today, 22:56
Joined
Jan 23, 2018
Messages
17
Hi all,

I am trying to achieve this:

On a form, I would like to display automatically the status of the current network connection of the computer where the database is running.

Additionally, I would also like Access to display whether a VPN connection is active or not on that form.

I tried My.Computer.Network.IsAvailable with no luck. Any ideas?
 

Minty

AWF VIP
Local time
Today, 21:56
Joined
Jul 26, 2013
Messages
10,371
You can test whether a certain network resource is available using this function to ping it;

Code:
Function SystemOnline(ByVal ComputerName As String)
    ' This function returns True if the specified host could be pinged.
    ' HostName can be a computer name or IP address.
    ' The Win32_PingStatus class used in this function requires Windows XP or later.
    ' Standard housekeeping
    Dim colPingResults As Variant
    Dim oPingResult As Variant
    Dim strQuery As String
    ' Define the WMI query
    strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & ComputerName & "'"
    ' Run the WMI query
    Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery(strQuery)
    ' Translate the query results to either True or False
    For Each oPingResult In colPingResults
        If Not IsObject(oPingResult) Then
            SystemOnline = False
        ElseIf oPingResult.StatusCode = 0 Then
            SystemOnline = True
        Else
            SystemOnline = False
        End If
    Next
End Function

And you can use
Code:
CreateObject("wscript.network").userdomain
to return the current domain the local computer is logged on to.
 

Users who are viewing this thread

Top Bottom