I have a search form that users can open an existing repair order or create a new repair order by selecting from the search results that show in a subform.
I want to do some error handling and the one procedure I'm having issues with is when a user types in a search and gets NO results but then clicks the Create R.O. button. The button will try to pass the [CustID] to the next form it opens, but the next form errors out because there is no value passed.
I want a Msg Box to display "No Customer Selected" and the button procedure to exit, but I'm not having any luck. Here is the code I've tried for the for the button.
I've tried it with: If IsNull(CustID), and If IsError(CustID). Every time the procedure runs and opens the "NewRepairOrder", but then gives me a Runtime error because it's missing the [CustID].
Any help would be greatly appreciated.
Thanks,
Dustin
I want to do some error handling and the one procedure I'm having issues with is when a user types in a search and gets NO results but then clicks the Create R.O. button. The button will try to pass the [CustID] to the next form it opens, but the next form errors out because there is no value passed.
I want a Msg Box to display "No Customer Selected" and the button procedure to exit, but I'm not having any luck. Here is the code I've tried for the for the button.
Code:
Private Sub CreateRO_Click()
If IsError(CustID) Then
MsgBox "No Customer Selected"
Exit Sub
End If
DoCmd.OpenForm "NewRepairOrder", , , , acFormAdd
Forms!NewRepairOrder.CustID = Me.[CustomerSearchSubForm].[Form]![CustID]
DoCmd.Close acForm, "CustomerSearch"
I've tried it with: If IsNull(CustID), and If IsError(CustID). Every time the procedure runs and opens the "NewRepairOrder", but then gives me a Runtime error because it's missing the [CustID].
Any help would be greatly appreciated.
Thanks,
Dustin