Error Message Question - Is this ok! (resolved)
Hey,
I have the following code:
On Error GoTo Errhandle
'Replace(frmSearchResult2.txtSurname.Text, "'", "''") As String
'Replace(frmSearchResult2.txtFirstName.Text, "'", "''") As String
'Replace(frmSearchResult2.txtAddress.Text, "'", "''") As String
Dim message As String
If cboTitle.Text = "" Then
message = MsgBox("Please enter a title for the customer", vbOKOnly, "Please enter a title")
Else
If txtSurname.Text .................[more code]
message = MsgBox("The changes have been made to the customer", vbOKOnly, "Changes Saved")
Unload Me
End If
End If
End If
End If
End If
End If
End If
Exit Sub
Errhandle:
If Err.Number = 1000 Then
message = MsgBox("Hhhmm")
Else
message = MsgBox("The program is generating an unidentified error. A number of issues may be occurring You may have included illegal symbols such as ',& or *. --> You may be trying to create an item that has certain dependencies in the database Example: In order to create an order you must have a related customer. --> If selecting an item from a datagrid ensure that you are selecting the item correctly. One or more of these may apply. Please check your action and try again. ", vbOKOnly, "Catch All Error Message")
Exit Sub
End If
End Sub
It's not the poor quality of the Error handling that I'm worried about (good thing) .. but unless I have the Exit Sub above the Errhandle the error message keeps showing up even when the code executes. Is this the best way to avoid the message or is there a proper way that I'm missing (or am I randomly right)
Thanks!
WAQ