Private Sub Form_BeforeUpdate(Cancel As Integer) If Not Nz(Me.cbopsdCode, "") = "" And IsNull(Me.numberOfpsd) Then MsgBox "Please enter the number of products!", vbInformation, "Atention!" Cancel = True Exit Sub End If End Sub
Did you remove the zero default value? Like I said, it will never be null or zls when there are default values. I'll have to see if it works when it's removed. Nz should return whatever you tell it to IF the value passed is Null. It's not like we're trying to set the value of a number field to a string, we're passing a value (or Null) to a function to see what it returns. If it's a number, that ought to be a number . If Null, it should be whatever you tell it to be.I can't explain why the test for a ZLS doesn't work with a numeric field
If Not Nz(Me.cbopsdCode, "") = "" And Nz(Me.numberOfpsd, "") = "" Then MsgBox "Please enter the number of products!", vbInformation, "Atention!" Cancel = True Exit Sub End If
Glad you finally got it solved.EDIT - first issue I see is that this will never work because you left the default value of 0 on number fields when you created the tables. So when you go to a new record, the textbox(es) will never be null. Remove that setting.