473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Test Internet Connection from within Access

759 512MB
Can I test the Internet Connection from within Access ?

I have a hyperlink field that contains URLs to web pages.
I like to test if the computer can access the Internet in order to enable/disable the control "GoToThisPage" in the related form.

Can that be done ? How ?

Thank you !
Nov 10 '12 #1

✓ answered by ADezii

The API can easily tell you as to whether or not you are connected to the Internet:
Expand|Select|Wrap|Line Numbers
  1. Public Declare Function InternetGetConnectedState Lib "wininet.dll" _
  2. (ByRef dwflags As Long, ByVal dwReserved As Long) As Long
Expand|Select|Wrap|Line Numbers
  1. Public Function GetInternetConnectedState() As Boolean
  2.   GetInternetConnectedState = InternetGetConnectedState(0&, 0&)
  3. End Function
Expand|Select|Wrap|Line Numbers
  1. Dim strConnected As String
  2.  
  3. strConnected = IIf(GetInternetConnectedState(), "Connected", "NOT CONNECTED")
  4.  
  5. MsgBox strConnected, vbInformation, "Internet Connected Status"

9 8659
Rabbit
12,516 Expert Mod 8TB
You can ping the address and see if that's successful.
Nov 11 '12 #2
zmbd
5,501 Expert Mod 4TB
Ping may not work 100% depending on the host file list, proxy, or other I.T. interferences.

For example... if I try to ping the IP for MSN at work... the ping will fail because the company DSN server traps all direct IP access; however, if I use the URL I Can connect without issue (well... unless the Internet is down)

What I have done is use automation to create an IE object, navigate to a known webpage and wait for the ready state to show valid. Requires the references for IE which adds some overhead but not much.

I've also ran across the "wininet.dll" and some code to use it; however, I've not had the time to really determine the usage so I'm not sure if it has the same issues as I've ran into with my I.T. - but it looks promising as there appears to be proxy detection.
Nov 11 '12 #3
Mihail
759 512MB
Thank you both for answers !
I'll try the suggestions and I'll inform you about the results.
Nov 12 '12 #4
ADezii
8,834 Expert 8TB
The API can easily tell you as to whether or not you are connected to the Internet:
Expand|Select|Wrap|Line Numbers
  1. Public Declare Function InternetGetConnectedState Lib "wininet.dll" _
  2. (ByRef dwflags As Long, ByVal dwReserved As Long) As Long
Expand|Select|Wrap|Line Numbers
  1. Public Function GetInternetConnectedState() As Boolean
  2.   GetInternetConnectedState = InternetGetConnectedState(0&, 0&)
  3. End Function
Expand|Select|Wrap|Line Numbers
  1. Dim strConnected As String
  2.  
  3. strConnected = IIf(GetInternetConnectedState(), "Connected", "NOT CONNECTED")
  4.  
  5. MsgBox strConnected, vbInformation, "Internet Connected Status"
Nov 18 '12 #5
zmbd
5,501 Expert Mod 4TB
ADezii
THANK YOU!
That makes me feel better about that API call... the code you posted is very similar to what I had found; however, I didn't understand it completely and I don't like to suggest something I don't understand.
Nov 18 '12 #6
ADezii
8,834 Expert 8TB
@zmbd:
Glad that everything was cleared up for you - my pleasure.
Nov 18 '12 #7
NeoPa
32,556 Expert Mod 16PB
If you have Windows API needs then there's a good chance that ADezii will be your man. He's done a lot of work in that area and has experience with all sorts of requirements :-)
Nov 18 '12 #8
Mihail
759 512MB
May I use this even if I don't understand very well ?
Thank you ADezii ! Good job !
Nov 19 '12 #9
ADezii
8,834 Expert 8TB
You are quite welcome, Mihail. You most certainly can use this functionality even if you do not fully understand the Code. The Code can actually be simplified by DELETING the Function altogether, eliminating the IIf() Construct, and making the API Call directly as in:
Expand|Select|Wrap|Line Numbers
  1. If InternetGetConnectedState(0&, 0&) Then
  2.   MsgBox "Connected"
  3. Else
  4.   MsgBox "NOT Connected"
  5. End If
P.S. - You would still need the API Declaration, namely:
Expand|Select|Wrap|Line Numbers
  1. Public Declare Function InternetGetConnectedState Lib "wininet.dll" _ 
  2. (ByRef dwflags As Long, ByVal dwReserved As Long) As Long
Nov 19 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: m004202002 | last post by:
I recently visited a site http://us.mcafee.com/root/speedometer/default.asp which find out the connection speed . Can any body explain how(logic) to do it ? Can i do that using php ? Please help...
6
by: Matt Hawley | last post by:
I'm facing a problem where I need to verify that my windows forms application has access to the internet before it can do anything. Currently, the only way I can think of is by creating a...
4
by: Peter Flynn | last post by:
I'm having trouble finding example code to detect the presence of an Internet connection. It doesn't seem to be a very frequently asked question, as all I need is the answer yes or no (is the user...
8
by: Jozef | last post by:
Hello, Is there a way to test that an internet connection exists and that you are able to see the webserver before performing any connections? The reason being, when I try to connect to an SQL...
3
by: Jonny | last post by:
Hi, Please could you tell me how to check for an internet connection in C. I'm using Windows 2000. Many Thanks, Jonny
15
by: ezmiller | last post by:
Does anybody know how to use javascript to test whether or not an internet connection exists? Is this possible even?
4
by: John Riddle | last post by:
Hello, I have an application that runs continously gives an error and stops working if the internet goes down (which happens for about 5-10 minutes several times a day. Can anybody tell me how...
6
by: =?Utf-8?B?QnNtZW5nZW4=?= | last post by:
I am trying to make sure that the local connection is up. I have presently been using the NetworkChange.NetworkAvailabilityChanged Event for this. Is there a better way to do this? Also, I...
1
by: =?Utf-8?B?QiBTaW5naA==?= | last post by:
Hi Scenario 1) Host - XP Laptop with internet connection using Sky Broadband Wireless Router Netgear DG834GT 2) MS Virtual Server 2005 - I have deployed an XP MS Virtual Server 2005 to act...
11
by: Alexnb | last post by:
Hello internet. I am wondering, is there a simple way to test for Internet connection? If not, what is the hard way :p -- View this message in context:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.