Capture "Your network access was interrupted" so can close/exit more controlled (1 Viewer)

bignose2

Registered User.
Local time
Today, 03:05
Joined
May 2, 2010
Messages
219
Hi,

I have a BE on a wired LAN.
Very rare for interruption but power outage or just resetting a Switch/AP without remembering to close all FE (I have 4) give me the above error.
I usually have to click 5 or 6 or more close or X on the window before access closes.

It can of course happen from many forms wherever the DB is currently open, also I do have a timer that checks in to the BE. I could error trap here but would prefer some sort of blanket check

I am assuming there is no way to do this without error checks everywhere but thought ask. I do have error handling in most places but not sure that helps as errors usually warn & continue or go back to previous forms etc & wherever you go it wants data from the BE.

Luckily (touch wood!!) I have never had data corruption but the more times I have to press OK or close I suspect more chance of a problem. A simple close straight off would be safer & easier, especially for my staff.

I have never thought of this in all my years but is there a way to have an error handler that catches if there is not other handling in the class or modules.

Thanks I/A
 

Isaac

Lifelong Learner
Local time
Yesterday, 19:05
Joined
Mar 14, 2017
Messages
8,774
Well ... this is kind of a "wild idea", but theoretically it is possible, I believe. You can write code (perhaps on a timer running from a hidden form that stays open all the time in your database), that tries to activate a named window. If it fails, nothing happens and the code keeps iterating, trying every few seconds. If it's successful, that means that particular window exists...and you can then do whatever you want to do.

I have used this with varying success in at least two contexts - one checking for incoming IM's and one checking for a windows explorer window.

There are all kinds of more complex, API-based methods for activating a window, handle, or task ID, but the simplest way to test this concept out is probably to just use AppActivate.

Just one idea to throw out there.

Code:
Function IsAppOpen(strAppName As String) As Boolean
On Error Resume Next
AppActivate strAppName
If Err.Number <> 0 Then
    IsAppOpen = False
Else
    IsAppOpen = True
End If
End Function

Edit: I just remembered, I should add that I think Shell's version of AppActivate actually returns a boolean/bit value. I'm not sure if there's anything better to that compared to testing for a VBA error on AppActivate. Just mentioning.
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:05
Joined
Feb 28, 2001
Messages
27,138
Here is another approach to that problem:


This next reference says it is error 3043, which means it is trappable. The problem is of course that the fix is to close and reopen the DB. That can't be done so easily through VBA code. (The CLOSE/QUIT is easy. It is the automatic re-open that is tough.)

 

ihelper

New member
Local time
Today, 07:35
Joined
Dec 9, 2020
Messages
1
fixed error 3040 To continue, close the database, and then open it again. more visit ihelper
 

Users who are viewing this thread

Top Bottom