Larry Haydn
Board Regular
- Joined
- Jul 18, 2019
- Messages
- 207
- Office Version
- 365
- Platform
- Windows
How do I check whether a network connection is active?
I could check whether a mapped network drive exists, using this:
The problem is, if the network crashed, the mapped drive still "exist", even though
visually it has a big red X on the drive letter.
-------------------------------------------------------------
Why do I need this?
I am using this check to determine whether the program should attempt a connection with SQL Server.
This means that if the network is active, I will establish a connection to SQL Server and save data there.
On the other hand, if the network is inactive, then save the data locally.
I could check whether a mapped network drive exists, using this:
VBA Code:
Dim HaveDrive As Boolean
HaveDrive = False
HaveDrive = CreateObject("Scripting.FileSystemObject").DriveExists("P")
If HaveDrive Then ....
The problem is, if the network crashed, the mapped drive still "exist", even though
visually it has a big red X on the drive letter.
-------------------------------------------------------------
Why do I need this?
I am using this check to determine whether the program should attempt a connection with SQL Server.
This means that if the network is active, I will establish a connection to SQL Server and save data there.
On the other hand, if the network is inactive, then save the data locally.