I'm checking the value of a text box on exit with a Select statment. I've tried several different methods but can't seem to find the correct way to trap a null or empty condtion.
I've tried these but they did not work for me:
Case Is = Empty
Case Is = ""
Case Is = Null, ""
Code ran fine but everytime my Case Else statement was triggered and not any of the other cases. I thought this might be due to the text box being bound to my primary key field ("new"?)so changed it to unbound with the same result. I found an example of using an If Isnull statement prior to the Select that works (I left it in my code sample) but it sure seems like there would be a way for Select Case to natively deal with nulls and zero length strings. TIA
Private Sub tbPOID_Exit(Cancel As Integer)
Dim strMsg, iResponse As String
If IsNull(Me.tbPOID) Or Me.tbPOID = "" Then
Me.tbPOID = "Null"
Select Case Me.tbPOID
MsgBox ("Null or Empty")
Me.tbPOID = "P"
strMsg = "You entered '" & Me.tbPOID & "' as a new Order." & _
vbCrLf & "Is this correct?"
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "New Order?")
If iResponse = vbNo Then
Cancel = True ' Cancel exit.
Exit Sub ' Save and continue.