Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Am I connected to the Network 2

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
Hello All,

I have a database. It may be on a desktop which has access to a network or a tablet pc which is not connected. I want to be able to determine if I am connected to the network via my code in my database.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
There are Win API calls that you can make to do that, but I just cheat.

Since none of my users know how to use the Subst or Net Use conmmands, they are unable to create virtual drives.

This means that by attempting to open a file on a network drive eg K:\MyFile.txt inside an Error Handler, I know that if the file is succerssfully opened, the user is connected; if the Error Handler is triggered, I know that they are not.

 
The FileSystemObject in the "Microsoft Scripting Runtime" library has some good directory methods:
Code:
Function DriveIsReady(ByVal drive As String) As Boolean
  Dim fso As New Scripting.FileSystemObject
  DriveIsReady = fso.DriveExists(drive)
End Function

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Both are very good approaches. Thanks alot guys.

We actually thought about opening the file. That confirms it can be done that way. I am going to look at slammer's way first. It seems more efficient.

Thanks again.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top