Null error

  • Thread starter Thread starter Hanksor
  • Start date Start date
H

Hanksor

I need to put an IF statement in the Sub below that check to see if
Me!Training is Null and if it is, set it to 0. I'm somewhat new to this and
I'm not sure of the syntax and my book is not with me.
This is a text box in a form.
Any help will be appreciated..

Private Sub cmdTrnPls_Click()
Dim CurAmount As Long
CurAmount = Me!Training + 500
Me!Training = CurAmount
End Sub
 
You can use NZ function,no need code.....
formula: NZ([name],0)
Aaron _~@
Yang _`\<,_
¡¡ (*)/&(*)
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
 
try this

Private Sub cmdTrnPls_Click()

Dim CurAmount As Long
CurAmount = Nz(Me!Training, 0) + 500
Me!Training = CurAmount

End Sub

the Nz() function says "use the value stated in front of the comma, unless
it's a Null value. in that case, use the value stated after the comma". in
effect, it's a neat little If statement just for Null situations.

hth
 
Thanks to both of you!!!! This worked perfectly.
Aaron said:
You can use NZ function,no need code.....
formula: NZ([name],0)
Aaron _~@
Yang _`\<,_
¡¡ (*)/&(*)
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
Hanksor said:
I need to put an IF statement in the Sub below that check to see if
Me!Training is Null and if it is, set it to 0. I'm somewhat new to this and
I'm not sure of the syntax and my book is not with me.
This is a text box in a form.
Any help will be appreciated..

Private Sub cmdTrnPls_Click()
Dim CurAmount As Long
CurAmount = Me!Training + 500
Me!Training = CurAmount
End Sub
 
Back
Top