I have written the following code for VB6
The application uses MS Access and used Microsoft Jet 4.0 OLEDM Provider

Private Sub cmdSubmit_Click()
 On Error GoTo Handler
 Eval_Env.Insert txtEvalCode.Text, txtEvalName.Text, txtEvalPhone.Text, 0
  Label4.Caption = "Data Submitted Successfully"
  Label4.Visible = True
 MsgBox "An error occurred"
 Label4.Visible = False
 Exit Sub
End Sub
Private Sub ClearControls()
txtEvalName.Text = ""
txtEvalCode.Text = ""
txtEvalPhone.Text = ""
End Sub

Private Sub txtEvalPhone_Validate(Cancel As Boolean)
If Not IsNumeric(txtEvalPhone.Text) Then
  txtEvalPhone.Text = ""
  Cancel = True
  End If
End Sub

When I run this, after submitting(click event of the command button) the above code gives msg "an error occurred" and then executes executes Label4.Visible = False.
But still the data is entered into the database.
The msgbox appears whether I give correct values in textboxes or wrong/incompatible values in the txtboxes. How to solve this ?
Although Database is updated only in case correct values r given.

A typical error handler goes something like this...

Private Sub Command1_Click(Index As Integer)

On Error GoTo Command1_ClickError

Exit Sub

End Sub

Now, looking at your code I can see you have the exit sub after the msgbox and not before the error handler label....

Good Luck

This question has already been answered. Start a new discussion instead.