If x is null then....

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm running an after update event on a form using the following code but it
seems like it is incorrect (VB won't run: I get a debug error)

If Me.Partial_Status = "Closed" And Me.Partial_Closed_On Is Null Then
Me.Partial_Closed_On = Now()
Me.Partial_Closed_by = CurrentUser()
End If

On the other hand, if I try the code below, it runs but doesn't give me the
expected result (I know for sure that the ME.PARTIAL_CLOSED_ON field is null
and it acts as if it wasn't):

If Me.Partial_Status = "Closed" And Me.Partial_Closed_On = Null Then
Me.Partial_Closed_On = Now()
Me.Partial_Closed_by = CurrentUser()
End If

I've been looking at this for hours and I can't figure out what is wrong.
Any help would be greatly appreciated.

Thanks in advance,
 
Hi Kanga,

You need to use the IsNull() function to test for null

If Me.Partial_Status = "Closed" And IsNull(Me.Partial_Closed_On) Then

HTH
Steve C
 
Back
Top