When entering visits they have to select a patient and a volunteer from dropdowns. The combos are initially empty, but if they select one and then inadvertently delete it, the error is: "You tried to assign a Null value to a variable that isn't a Variant data type."
They can correct it by selecting another item from the list, but if they don't do that then it leads to continual errors that I can only stop by crashing out of Access.
I want to catch that error, provide my own instructions, and return the combo to it's previous value (or reset it to nothing and clear the first and last names that it automatically populates). I've tried to catch it with BeforeUpdate and Change, but the Access error kicks in before either of them. I found this online, but it didn't work either:
Code: Select all
Private Sub cmbPID_Exit(Cancel As Integer) If Nz(Me.cmbPID.Text, "") = "" Then MsgBox "This field cannot be empty. Either select a patient or clear the form." Cancel = True End If End Sub