I have a search button on my menu form that, when clicked, asks the user to enter a desired Reference number they wish to search for. This works fine when it is a Reference number that is stored within the database.
I have tested it to see if it works with reference numbers that do not exist, and instead of giving an error message to ask them to retry, it opens up the form to a new record... That is not what I want it to do.
Please can someone help me, here if my code up to yet (not sure if the msgbox is correct btw):
I have tested it to see if it works with reference numbers that do not exist, and instead of giving an error message to ask them to retry, it opens up the form to a new record... That is not what I want it to do.
Please can someone help me, here if my code up to yet (not sure if the msgbox is correct btw):
Code:
Private Sub cmdSearchSite_Click()
On Error GoTo Err_cmdSearchSite_Click
DoCmd.OpenQuery "qrySearchRTP"
DoCmd.OpenForm "FRM_PRIMARY"
DoCmd.GoToRecord acDataForm, "FRM_PRIMARY"
DoCmd.Close acQuery, "qrySearchRTP"
DoCmd.Close acForm, "FRM_MENU"
Exit_cmdSearchSite_Click:
Exit Sub
Err_cmdSearchSite_Click:
MsgBox ("Site not found. Please enter a valid RTP Reference Number")
Resume Exit_cmdSearchSite_Click
End Sub