Sabtu, 27 Juni 2015

Re: [MS_AccessPros] Problem on error procedure

 

Valentino-


For the code to keep running, you have to use Resume.  I assume you want to pick up execution at somewhere other than "Next".  The way to do that is to consecutively number your lines of code and then use Resume LineNo to clear the error and go to where you want to keep processing.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Jun 27, 2015, at 9:19 AM, Valentino Avvisati valentino.avvisati@gmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Good morning,
I have one issue with error procedure
There is one function (number 1) that call the function number 2 giving it  two variables
In function number 2 there is an error procedure:
At the beginning there is this line that call the error procedure

 

 

"On Error GoTo errhandler"

 

At the end of this mail there is written the error procedure

 

The function 2  read a table using do loop cycle  where is written the path where find many excel sheet to be imported using the command:

 

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, destable, filenamefinale, False, des & "!"

 

 

The case "case 3125" appear when the name of the file  that is in the table that the do loop cycle read,  is not found in excel sheet
The procedure tell to the operator that the sheet there Is not in the file and go to the end of the loop to read next sheet.
effectively  the error procedure is working the first time  the procedure find this issue and bypass it going on to the next, but going  on reading using the doo loop  cycle, one  time that find another error with the same code 3125, it look like the error procedure is not anymore working and the program stop showing the error 3125 as if the error procedure is not active.
My goal  is that each time one sheet Is not find bypass it, but actually this occur only the first time.

 

 

Somebody have some idea why occur this issue and how to solve?
Thank you  to all

 

Valentino

 

errhandler:
Select Case Err

 

    Case 2391

   

        db.TableDefs.Delete destable
        Resume
    Case 3078:

   

        varia = 1
        Err.Clear
        Resume Next

       

   

    Case 3125
        MsgBox "I do not find the sheet named " & des & "This Sheet will be bypassed"
        varia = 0
        Err.Clear

     

       

        GoTo fine

   

   

   

    Case Else:     
           MsgBox "Error # " & Err & " : " & Error(Err)

 

   

   

End Select


__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar