I have loop reading text file and import data from it to DB. File name consist of date and at the end of loop I increase the date for 1 day and create the file name to read the next file.
I am trying to solve the problem of error handling on duplicate entries with the foloving code:
[tt]
Private Sub cmdImportPC_Click()
...some code
[highlight]
start:
On Error GoTo errorhandler
[/highlight]
:
Loop to import data to DB
:
Exit Sub
[highlight]errorhandler:
skip (increment file name) to the next file ()
goto start[/highlight]
End Sub
[/tt]
The problem is next:
The first time duplicate entry error rises the code in errorhandling section is executed and there is no problem, the code goes to [tt]start:[/tt] and does all the job. The second time the program tries to insert a duplicate entry the code in errorhandling section is NOT executed, insted of this the system error message popups with the same error number. The program must be terminated.
Why the same error is not cathed with the error handler?
I am trying to solve the problem of error handling on duplicate entries with the foloving code:
[tt]
Private Sub cmdImportPC_Click()
...some code
[highlight]
start:
On Error GoTo errorhandler
[/highlight]
:
Loop to import data to DB
:
Exit Sub
[highlight]errorhandler:
skip (increment file name) to the next file ()
goto start[/highlight]
End Sub
[/tt]
The problem is next:
The first time duplicate entry error rises the code in errorhandling section is executed and there is no problem, the code goes to [tt]start:[/tt] and does all the job. The second time the program tries to insert a duplicate entry the code in errorhandling section is NOT executed, insted of this the system error message popups with the same error number. The program must be terminated.
Why the same error is not cathed with the error handler?