Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Trapping Problem... 2

Status
Not open for further replies.

DTJeff

Programmer
Dec 9, 2003
37
GB
Hi all.

I have a wierd problem and I'm not sure if its just me, or if it is an actual problem.

Basically I have a function to insert a record into my SQL DB, and if a primary key violation has happened, then I handle the error by showing a message box, and then allowing the user to re-enter the data. This works fine.

The problem occurs if the user tries to do it again for a second time, an error is generated, but handled by VB rather than my code.

Essentially my code is:

On Error Goto ErrorHandler

StartCreate:

frmDataEntry.show 1 'Show as a modal form
'on return from the form, do this:
CreateRecord "Data","etc","etc" '(CreateRecord is a command in the data environment)

Exit Function

ErrorHandler:
msgbox err.number & err.description
err.clear
goto StartCreate

Any Ideas?

Thanks all.
 
Thanks - A star awarded.

That did the trick, I cant beleive I missed something that stupid. oh well, you live and learn.

Jeff
 
You might want to count the amount of loops done whilst in error and set a point at which to escape the loop or be stcuk in it forever
 
Hi,

Thats an idea, but in this case it is unneeded as every time the loop happens, a user has to enter the data into a form, if the user enters valid data or cancels the entry, then the routine loop will end.

Jeff.
 
Paulbent - a star for you! It's amazing, if you search this forum, most questions have been answered!

Thanks Paul

BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top