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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Trapping!

Status
Not open for further replies.

75cl

Programmer
Joined
Nov 1, 2001
Messages
43
Location
US
What is a good way of traping error under this situation. let say i am importing data from the excel worksheet to a flexgrid using adodb connection. and I want to be able to continue my importing process when an error arise and be able to keep track of the number of bad record and good record. Anyone have any good idea of how to approach this. Thank you in advance
 
Hi,
You've got two types of errors to trap for. 1 where data in the Excel sheet is missing or invalid and causes ADO to error or 2 the Flex grid errors on update which in my experience is very rare. You could trap the errors with an on error goto and resume and the bottom of the loop so the next record is then accessed and either message box the row number where the error occurred or write the Excel data out to an error.txt file for later examination.

Hope this helps

Nick W
 
I like to trap them where they live
Code:
Dim lngErr as long
Dim strErr as string

On Error Resume next
    yadda
    lngerr = err.Number
    if lngerr <> 0 then strErr = Err.Description
On error goto 0
If LngErr <> 0 then
    Checkerror lngErr,strErr ' Come back only if OK, else Err.Raise
else
    ProcessRecord .....,...
End if
Compare Code (Text)
Generate Sort in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top