Hi, I keep getting the error message type mismatch 13 when I enter in
characters instead of numbers. I'm trying to display my own error
message instead so the program won't stop. Can anyone please help. The
code is below. Thank you.
Private Sub cmdSearch_Click()
Dim intID As Integer
'Get the student ID and set it to intID
intID = InputBox("Enter a Student's ID", "Get ID")
'If an error occurs go to HandleError
On Error GoTo HandleError
'Refresh the database and move to the first record
'find the first match to intID in database
frmStudents!datStudents.Refresh
frmStudents!datStudents.Recordset.MoveFirst
frmStudents!datStudents.Recordset.FindFirst "StuID = " & intID
'If no match found then display error message and clear all
'text box fields
If frmStudents!datStudents.Recordset.NoMatch Then
MsgBox "ID not found in database", _
vbOKOnly, "ID Not Found Error"
txtInstrID = ""
txtName = ""
txtRank = ""
txtAddress = ""
txtCity = ""
txtState = ""
txtPhone = ""
txtExperience = ""
txtZip = ""
End If
HandleError:
'Get the error title
strErrTitle = Err & " " & Error$
Select Case Err
'If error = 3314 then display error message
Case 13
MsgBox "You need to enter in numbers only for student's ID",
_
vbQuestion, strErrTitle
End Select
'Execute the next statement after On Error above
Resume Next
End Sub