Error handling within error handler.

Fuga

Registered User.
Local time
Today, 13:55
Joined
Feb 28, 2002
Messages
566
Hi,

I have an error handler in a procedure which executes when an error occurs in the "main" procedure. However, the same error might occur inside the error handler, so I need an error handler inside the error handler.

I tried to just have a second error handler, but you can´t do it that way, can you?

After the error handler, the "main procedure is supposed to continue (Resume Next).

Do I have to split the sub?

Thanks


Fuga.
 
Let's see the ErrorHandler and what error could occur?
 
Thanks for the quick reply.

This is a part of a "data fetching" routine I use to get information from the web. Depending on certain things, the data will vary slightly, so that I cannot use one macro (in word, which I run from access). I solved this by making two copies of the downloaded text file, and running three seperate macros.

When the error occurs, it´s an "invalid use of null" in the middate = rsquote.fields("field9") line.

This is because the word macro for the first file didn´t work (therefore the text file is now empty).

What I need now is the same thing, if the second text file doesn´t work.

There can be only three variations.

Code:
Sub datefix()
On Error GoTo erImport

Dim rsquote As DAO.Recordset, rsAFV As DAO.Recordset
Dim predate As String, middate As String


Set rsquote = CurrentDb.OpenRecordset("quote")
rsquote.MoveFirst
middate = rsquote.Fields("Field9")
predate = CStr(Date)
middate = predate & " " & middate & ":00"
rsquote.Edit
rsquote.Fields("Field9") = middate
rsquote.Update
rsquote.Close

Set rsAFV = CurrentDb.OpenRecordset("AFVlog")
    rsAFV.MoveFirst
    Do While Not rsAFV.EOF
        rsAFV.Edit
        rsAFV.Fields("field2") = middate
        rsAFV.Update
        rsAFV.MoveNext
    Loop
    rsAFV.Close
    
Exit Sub

erImport:
On Error GoTo erimport2
    rsquote.Close
    CurrentDb.TableDefs.Delete ("quote")
    CurrentDb.TableDefs.Delete ("quote_importerrors")
    DoCmd.TransferText , "quote import specification", "quote", "c:\data\looser.txt"
    Set rsquote = CurrentDb.OpenRecordset("quote")
    rsquote.MoveFirst
    middate = rsquote.Fields("field9")
    Resume Next
    Exit Sub

erimport2:
    rsquote.Close
    CurrentDb.TableDefs.Delete ("quote")
    CurrentDb.TableDefs.Delete ("looser_importerrors")
    DoCmd.TransferText , "quote import specification", "quote", "c:\data\neutral.txt"
    Set rsquote = CurrentDb.OpenRecordset("quote")
    rsquote.MoveFirst
    middate = rsquote.Fields("field9")
    Resume Next
    Exit Sub

End Sub

Fuga.
 
Why not, before you try to assign the value, use the IsNull() function to test if it's possible?

Code:
If IsNull(rsquote.fields("field9")) =False Then
    middate = rsquote.fields("field9")
End If
 
:o
Indeed, why not.

I´ll try it.

Thanks.

Fuga.
 

Users who are viewing this thread

Back
Top Bottom