UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Any Way To Trap A Specific Network Error?, Access 2016    
 
   
basson
post Nov 22 2017, 01:08 PM
Post#1



Posts: 873
Joined: 26-March 02
From: St.Louis, MO, USA


I do some very basic error handling in my DBs which will log the error in a table, pause the db and then make a few more attempts before closing out and sending an email via an open outlook session.
This has handled my needs until recently when I starter receiving the following network connection error on occasion.
"Run-Time error: 3043
Your network access was interrupted..."
Because this error is due to a loss of network connectivity, my error handling itself crashes because it of course cannot write back to the log table in the db which is on the network nor send an email.

So, in the case of this error, is there any way I can identify specifically when this occurs and choose to take another action that is not dependent on a network connection, such as just a pause longer or exit the db or to trigger a bat file to refresh drive mapping network connections?

I have no idea how to programatically identify and capture the specific error or if it is even possible.

Here is what I am currently doing:

ERR_INTERATION = 0
On Error GoTo Err_Handler

blah blah blah

Err_Handler:
SQL = "INSERT INTO [error_count] ([error], [time]) " _
& "VALUES ( '" & Title & "', #" & Now() & "#);"
CurrentDb.Execute (SQL)
If ERR_INTERATION > 2 Then


Set myOlApp = Nothing
Set myitem = Nothing
Set MyDB = Nothing
Set MyEL = Nothing
DB_FAIL Err.Description, Title ( the email)
Exit Function
Go to the top of the page
 
DanielPineault
post Nov 22 2017, 01:16 PM
Post#2


UtterAccess VIP
Posts: 6,072
Joined: 30-June 11



You may want to review: https://answers.microsoft.com/en-us/msoffic...fd-3d9d86a413c0

but, no, to my knowledge there is little you can do about this.

Send your feedback to Microsoft through the Feedback option in Access and through access.uservoice.com, hopefully, one day, perhaps, they might address it... if they feel like it, but don't get your hopes up... sad.gif

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
DanielPineault
post Nov 22 2017, 01:19 PM
Post#3


UtterAccess VIP
Posts: 6,072
Joined: 30-June 11



Also, since this error means you have no access to the BE, your error handler can't work as is (trying to insert a record into a table). You should modify your code, perhaps by simply starting the error handler with On Error Resume Next.

CODE
ERR_INTERATION = 0
On Error GoTo Err_Handler

blah blah blah

Err_Handler:
On Error Resume Next
SQL = "INSERT INTO [error_count] ([error], [time]) " _
& "VALUES ( '" & Title & "', #" & Now() & "#);"
CurrentDb.Execute (SQL)
If ERR_INTERATION > 2 Then

Set myOlApp = Nothing
Set myitem = Nothing
Set MyDB = Nothing
Set MyEL = Nothing
DB_FAIL Err.Description, Title ( the email)
Exit Function

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
kfield7
post Nov 22 2017, 01:24 PM
Post#4



Posts: 875
Joined: 12-November 03
From: Iowa Lot


Have you considered

Err_Handler:
if Err.Number = 3043 then
'3043 Error handling
else

SQL = "INSERT INTO [error_count] ([error], [time]) " _
& "VALUES ( '" & Title & "', #" & Now() & "#);"
CurrentDb.Execute (SQL)
If ERR_INTERATION > 2 Then
' no end if? What if it's the 1st [interation]?


'end if ' all errors--- whether 3043 or not, you probably want a clean close out.
'end if '3043 check
Set myOlApp = Nothing
Set myitem = Nothing
Set MyDB = Nothing
Set MyEL = Nothing
DB_FAIL Err.Description, Title ( the email)

Exit Function
Go to the top of the page
 
basson
post Nov 22 2017, 02:43 PM
Post#5



Posts: 873
Joined: 26-March 02
From: St.Louis, MO, USA


I'll take a look at the "iferr.number" suggestion if that will work. Maybe that is what I am looking for...assuming this particular error always presents the same number.

The "On Error Resume Next" would not really work because Next would be to continue interacting with the back end which is not available at that time thus a continual error loop maybe?
Go to the top of the page
 
kfield7
post Nov 22 2017, 04:02 PM
Post#6



Posts: 875
Joined: 12-November 03
From: Iowa Lot


Resume...next would eventually get past the code causing the error (the need for a connection) within the referenced procedure or function, but that may not be the desired affect and lead to other errors.
Go to the top of the page
 
WildBird
post Nov 22 2017, 07:20 PM
Post#7


UtterAccess VIP
Posts: 3,382
Joined: 19-August 03
From: Auckland, Little Australia


Instead of writing to a database, have you thought of a text file? That's what I do, write a text file, and have it pipe delimited. Can be linked to and looks like a table etc.

--------------------
Beer, natures brain defragging tool.
Go to the top of the page
 
kfield7
post Nov 24 2017, 12:28 PM
Post#8



Posts: 875
Joined: 12-November 03
From: Iowa Lot


Wildbird, that's an interesting idea, but may (or not?) be problematic.

Basson wants to compile the errors in the BE on the server, I assume to have one location for all errors for debugging?. So you could append error text to a server based error file - the connection issue may pop up again? I haven't had this issue so I haven't tried it. Or, write the text file local - but then it would have to be retrieved local or via remote.

Maybe have it attempt to write to the server (whether table or external text file) xxx number of attempts to gain the connection, until successful? Send an email to IT?
Just throwing out ideas.
Go to the top of the page
 
WildBird
post Nov 28 2017, 01:30 AM
Post#9


UtterAccess VIP
Posts: 3,382
Joined: 19-August 03
From: Auckland, Little Australia


Yeah, if its a network issue, writing to a file on the network wont work. Maybe write locally to a text file might help. Just hard to get that data to somewhere where it can be analysed etc. Maybe have something that copies any local error file to network drive on opening main form or something?

--------------------
Beer, natures brain defragging tool.
Go to the top of the page
 
DanielPineault
post Nov 28 2017, 09:03 AM
Post#10


UtterAccess VIP
Posts: 6,072
Joined: 30-June 11



You could write locally when the network is down, and then periodically check and write the local file's content to the db when the network is functional again.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
basson
post Jan 9 2018, 11:21 AM
Post#11



Posts: 873
Joined: 26-March 02
From: St.Louis, MO, USA


Thanks for all the suggestions on this. I've been out sick and holiday time off but had set up the below before I left.

I've been playing with this for a while. Hard to know what would work as I cannot forcefully recreate the '3043' error on my own and it has not happened in a while.

On Error Resume Next did not work, and I imagine any type of writing, be it to a table on the db or out to a text file on the network or C: would fail due to the network connectivity loss as it would seem to me when running a back end db from my desktop and you lose network connection then the VBA code is being run on the desktop not on the server...so it cannot communicate back\forth to tell it to do anything.

I have simply decided to implemented this and will have to wait and see what it does if it can even do that.

If Err.Number = 3043 Then
DoCmd.Quit acExit
Else
........
............

I have the Windows task scheduler launching this db hourly to refresh reports with new data, so the best thing to do is shut it down if possible when the error occurs so it can run again later assuming the connection is back. The main problem was that the hourly re-launch would crash if the previous run was hung and left Access with an error on the screen.

We'll see.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    25th September 2018 - 03:54 PM