Hi all.
Simple question, but If I run a query that looks for a serial or reference number in a table, where and how do I trap the resulting error when the number isn't found in the table?
Form 1 is bound to a table. A button on form 1 launches form 2, a small dialog form with a few text boxes. (I am using just one text box at the moment.) The user enters a reference number in this text box and presses the search button. The code for this button is below. The query is designed to recieve the content of the textbox as it's criteria.
When a non existant number is entered the error catching on the button doesn't kick in, so where DO I catch it please? Thanks.
Simple question, but If I run a query that looks for a serial or reference number in a table, where and how do I trap the resulting error when the number isn't found in the table?
Form 1 is bound to a table. A button on form 1 launches form 2, a small dialog form with a few text boxes. (I am using just one text box at the moment.) The user enters a reference number in this text box and presses the search button. The code for this button is below. The query is designed to recieve the content of the textbox as it's criteria.
When a non existant number is entered the error catching on the button doesn't kick in, so where DO I catch it please? Thanks.
Code:
Private Sub btnSearchIncidents_Click()
On Error GoTo Err_btnSearchIncidents_Click
DoCmd.OpenForm "frmAnalysis", acNormal
Forms!frmAnalysis.lblAnalysisFormTitle.Caption = "Showing single selected record by number"
Forms!frmAnalysis.RecordSource = "qrySearchByNumber"
DoCmd.GoToRecord , , acLast
DoCmd.Close acForm, "frmChooseIncidentsToView", acSaveNo
Exit_btnSearchIncidents_Click:
Exit Sub
Err_btnSearchIncidents_Click:
MsgBox Err.Description
Resume Exit_btnSearchIncidents_Click
End Sub