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: 848
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: 5,451
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 ...
Go to the top of the page
 
DanielPineault
post Nov 22 2017, 01:19 PM
Post#3


UtterAccess VIP
Posts: 5,451
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 ...
Go to the top of the page
 
kfield7
post Nov 22 2017, 01:24 PM
Post#4



Posts: 774
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: 848
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: 774
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,278
Joined: 19-August 03
From: Perth, 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: 774
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,278
Joined: 19-August 03
From: Perth, 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: 5,451
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 ...
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    14th December 2017 - 10:21 AM