I have a button on a form to search for a document by a number that the user inputs. It works great as far as finding the correct document, but the problem is that if there is no match, it automatically opens up a new blank document. I have tried all different error messages, etc. and can't figure out how to have it just give a message that says "Record not found" and just exit sub. Here is the code....can anyone help??
Private Sub Command12_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim stInput As String
stInput = InputBox("Enter CPR/Task Number to Find", "Search for CPR/Task")
stDocName = "Business Requirement Document"
stLinkCriteria = "[BRD Number]=" & stInput
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
Private Sub Command12_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim stInput As String
stInput = InputBox("Enter CPR/Task Number to Find", "Search for CPR/Task")
stDocName = "Business Requirement Document"
stLinkCriteria = "[BRD Number]=" & stInput
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub