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 !
The API can easily tell you as to whether or not you are connected to the Internet: - Public Declare Function InternetGetConnectedState Lib "wininet.dll" _
-
(ByRef dwflags As Long, ByVal dwReserved As Long) As Long
- Public Function GetInternetConnectedState() As Boolean
-
GetInternetConnectedState = InternetGetConnectedState(0&, 0&)
-
End Function
- Dim strConnected As String
-
-
strConnected = IIf(GetInternetConnectedState(), "Connected", "NOT CONNECTED")
-
-
MsgBox strConnected, vbInformation, "Internet Connected Status"
9 8659
You can ping the address and see if that's successful.
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.
Thank you both for answers !
I'll try the suggestions and I'll inform you about the results.
The API can easily tell you as to whether or not you are connected to the Internet: - Public Declare Function InternetGetConnectedState Lib "wininet.dll" _
-
(ByRef dwflags As Long, ByVal dwReserved As Long) As Long
- Public Function GetInternetConnectedState() As Boolean
-
GetInternetConnectedState = InternetGetConnectedState(0&, 0&)
-
End Function
- Dim strConnected As String
-
-
strConnected = IIf(GetInternetConnectedState(), "Connected", "NOT CONNECTED")
-
-
MsgBox strConnected, vbInformation, "Internet Connected Status"
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.
@zmbd:
Glad that everything was cleared up for you - my pleasure.
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 :-)
May I use this even if I don't understand very well ?
Thank you ADezii ! Good job !
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: - If InternetGetConnectedState(0&, 0&) Then
-
MsgBox "Connected"
-
Else
-
MsgBox "NOT Connected"
-
End If
P.S. - You would still need the API Declaration, namely: - Public Declare Function InternetGetConnectedState Lib "wininet.dll" _
-
(ByRef dwflags As Long, ByVal dwReserved As Long) As Long
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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
|
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?
|
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...
|
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...
|
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...
|
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:...
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |