PC Review


Reply
Thread Tools Rate Thread

Detect if connected to the network

 
 
Rod
Guest
Posts: n/a
 
      22nd Feb 2007
I have an Access vba applications that picks up a small text file from
across a local network. If the user is not connected to the network I want
to do something else.

The trouble is that if I try and get the file, or even just check that it is
there by using FileSystemObjects the user's computer spends a long time
trying to access the network, when it fails I can catch the error. However
by then the user has got bored and probably assumed the program has crashed.

Is there a way in VBA of quickly detecting if you are connected to the
network, of if a particular network drive is available.

Thanks in advance.

Rod



 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFuaWVs?=
Guest
Posts: n/a
 
      22nd Feb 2007
This post might have the answer you seek.

http://groups.google.ca/group/micros...a79c73881e036d

Daniel





"Rod" wrote:

> I have an Access vba applications that picks up a small text file from
> across a local network. If the user is not connected to the network I want
> to do something else.
>
> The trouble is that if I try and get the file, or even just check that it is
> there by using FileSystemObjects the user's computer spends a long time
> trying to access the network, when it fails I can catch the error. However
> by then the user has got bored and probably assumed the program has crashed.
>
> Is there a way in VBA of quickly detecting if you are connected to the
> network, of if a particular network drive is available.
>
> Thanks in advance.
>
> Rod
>
>
>
>

 
Reply With Quote
 
Rod
Guest
Posts: n/a
 
      22nd Feb 2007
Thanks this looks to work well. Not sure what happens if there is a LAN but
it is not connected to the Internet.


"Daniel" <(E-Mail Removed)> wrote in message
news:0FE98366-55F4-41C8-9F3D-(E-Mail Removed)...
> This post might have the answer you seek.
>
> http://groups.google.ca/group/micros...a79c73881e036d
>
> Daniel
>
>
>
>
>
> "Rod" wrote:
>
>> I have an Access vba applications that picks up a small text file from
>> across a local network. If the user is not connected to the network I
>> want
>> to do something else.
>>
>> The trouble is that if I try and get the file, or even just check that it
>> is
>> there by using FileSystemObjects the user's computer spends a long time
>> trying to access the network, when it fails I can catch the error.
>> However
>> by then the user has got bored and probably assumed the program has
>> crashed.
>>
>> Is there a way in VBA of quickly detecting if you are connected to the
>> network, of if a particular network drive is available.
>>
>> Thanks in advance.
>>
>> Rod
>>
>>
>>
>>



 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      22nd Feb 2007
Is the file stored on drive somewhere on the network? You can check for
it's existence using the DIR function. That is pretty quick

If Len(Dir("J:\shared\spencer\ICD9.mdb")) = 0 then
'No such file available - although the network could be up
Else
'The file exists and is available
End IF


You can also check for a directory existing or even a mapped drive
IF Len(Dir("R:",vbDirectory)) = 0 then

Else

End If
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Rod" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks this looks to work well. Not sure what happens if there is a LAN
> but it is not connected to the Internet.
>
>
> "Daniel" <(E-Mail Removed)> wrote in message
> news:0FE98366-55F4-41C8-9F3D-(E-Mail Removed)...
>> This post might have the answer you seek.
>>
>> http://groups.google.ca/group/micros...a79c73881e036d
>>
>> Daniel
>>
>>
>>
>>
>>
>> "Rod" wrote:
>>
>>> I have an Access vba applications that picks up a small text file from
>>> across a local network. If the user is not connected to the network I
>>> want
>>> to do something else.
>>>
>>> The trouble is that if I try and get the file, or even just check that
>>> it is
>>> there by using FileSystemObjects the user's computer spends a long time
>>> trying to access the network, when it fails I can catch the error.
>>> However
>>> by then the user has got bored and probably assumed the program has
>>> crashed.
>>>
>>> Is there a way in VBA of quickly detecting if you are connected to the
>>> network, of if a particular network drive is available.
>>>
>>> Thanks in advance.
>>>
>>> Rod
>>>
>>>
>>>
>>>

>
>



 
Reply With Quote
 
Karl E. Peterson
Guest
Posts: n/a
 
      22nd Feb 2007
John Spencer <(E-Mail Removed)> wrote:
> Is the file stored on drive somewhere on the network? You can check for
> it's existence using the DIR function. That is pretty quick


Just buttin' in to say the commonly accepted practice is to use Attrib() rather than
Dir() for simple file existence checks, because using Dir releases any existing open
search handle that Dir may have created elsewhere in the application. (Kinda like
using FreeFile rather than hardcoding a specific file handle.) Ex:

Public Function FileExists(ByVal FileName As String) As Boolean
Dim nAttr As Long
' Grab this files attributes, and make sure it isn't a folder.
' This test includes cases where file doesn't exist at all.
On Error GoTo NoFile
nAttr = GetAttr(FileName)
If (nAttr And vbDirectory) <> vbDirectory Then
FileExists = True
End If
NoFile:
End Function

Public Function FolderExists(ByVal PathName As String) As Boolean
Dim nAttr As Long
' Grab the attributes, test valid values for folder bit.
On Error GoTo NoFolder
nAttr = GetAttr(PathName)
If (nAttr And vbDirectory) = vbDirectory Then
FolderExists = True
End If
NoFolder:
End Function

Carry on...
--
..NET: It's About Trust!
http://vfred.mvps.org


 
Reply With Quote
 
Rod
Guest
Posts: n/a
 
      22nd Feb 2007
Thanks, that's neat.


"Karl E. Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> John Spencer <(E-Mail Removed)> wrote:
>> Is the file stored on drive somewhere on the network? You can check for
>> it's existence using the DIR function. That is pretty quick

>
> Just buttin' in to say the commonly accepted practice is to use Attrib()
> rather than Dir() for simple file existence checks, because using Dir
> releases any existing open search handle that Dir may have created
> elsewhere in the application. (Kinda like using FreeFile rather than
> hardcoding a specific file handle.) Ex:
>
> Public Function FileExists(ByVal FileName As String) As Boolean
> Dim nAttr As Long
> ' Grab this files attributes, and make sure it isn't a folder.
> ' This test includes cases where file doesn't exist at all.
> On Error GoTo NoFile
> nAttr = GetAttr(FileName)
> If (nAttr And vbDirectory) <> vbDirectory Then
> FileExists = True
> End If
> NoFile:
> End Function
>
> Public Function FolderExists(ByVal PathName As String) As Boolean
> Dim nAttr As Long
> ' Grab the attributes, test valid values for folder bit.
> On Error GoTo NoFolder
> nAttr = GetAttr(PathName)
> If (nAttr And vbDirectory) = vbDirectory Then
> FolderExists = True
> End If
> NoFolder:
> End Function
>
> Carry on...
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>



 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      23rd Feb 2007
Rod wrote:
> Is there a way in VBA of quickly detecting if you are connected to the
> network, of if a particular network drive is available.
>



http://msdn2.microsoft.com/en-us/library/s6wt333f.aspx


Hope that helps

Tim F


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
detect computer connected to network Alain R. Microsoft C# .NET 1 22nd Sep 2007 06:00 PM
Network Connection Icon - Shows Not Connected when am Connected. =?Utf-8?B?R1c=?= Windows XP General 1 30th Jun 2007 06:07 PM
Detect speed connected to Local Network SurveyorinVA via AccessMonster.com Microsoft Access VBA Modules 2 15th May 2007 02:09 AM
to detect the clients connected in a network ravi kumar via .NET 247 Microsoft Dot NET Compact Framework 0 7th Mar 2005 07:04 PM
how to detect that the WAN connected? assaf Microsoft Dot NET Framework 0 26th Nov 2004 12:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:43 AM.