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

How can I check if An Error is returned

Status
Not open for further replies.

odessa79

Programmer
Sep 16, 2003
31
US
I have this code which works am tring to put in some error hadling how ca I do that? I want to check for an error before Execute statement.

Private Sub cmdAddTaskToProject_Click()
Set cmd = New ADODB.Command

With cmd
.ActiveConnection = cn400
.CommandText = "INSERT INTO ENPRAWD02.PRJTSKPF " _
& " (PRJNBR, TSKNBR, ESTHRS, ESTSTRDAT, ESTCMPDAT, ACTHRS, ACTSTRDAT, ACTCMPDAT, TSKSQN) " _
& " VALUES(" & gProjectNumber & ", " _
& " " & Trim(txtTaskNumber.Text) & ", " _
& " " & Trim(txtEstimatedHours.Text) & ", " _
& " " & Trim(txtEstimatedStartDate.Text) & ", " _
& " " & Trim(txtEstimatedCompletionDate.Text) & ", " _
& " " & Trim(txtActualHours.Text) & ", " _
& " " & Trim(txtActualStartDate.Text) & ", " _
& " " & Trim(txtActualCompletionDate.Text) & ", " _
& " " & Trim(txtTaskSequence.Text) & " ) " _

.Execute
MsgBox "Task number " & gTaskNumber & " has been added to Project number " & gProjectNumber & " "
End With
cmdExit_Click
End Sub
 
Put this before your "with" block:
On Error goto Err_Catch

...
and after the cmdExit_Click:
Err_Catch:
msgbox "An Error occured: " & vbCrLf & Err.Description
Err.Clear
Resume


This will inform you of occurred errors, but will allow you to keep working...
;-)
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top