Date Value in VBA

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

Guest

I have been pulling my hair up since yesterday. Here is the deal:
I have a form based on a table. I have a field named InitialTraining, which
is a date field. I am writing some code to mess around with this date field
but when it comes to checking if it is null or empty (either no date has been
entered or i am on a new record page on the form where nothing has been
entered yet, in any fields - thus the record does not exist yet), it bugs!!
Let's write it:
If Me.InitialTraining is Null Then
Blabla
End If

VBA returns me an error on the line "Me.InitialTraining si Null"

I dont get it, especially because when i write stuff like "If
Me.InitialTraining > Date..." it works fine.

Please help me guys!!! I am getting bold!!!!!!!
Alec
 
Alec,

You have to use the isnull function which returnns true if a value is null.
Like this:

If IsNull(Me.InitialTraining) = True then ...

HTH,
Josh
 
I have been pulling my hair up since yesterday. Here is the deal:
I have a form based on a table. I have a field named InitialTraining, which
is a date field. I am writing some code to mess around with this date field
but when it comes to checking if it is null or empty (either no date has been
entered or i am on a new record page on the form where nothing has been
entered yet, in any fields - thus the record does not exist yet), it bugs!!
Let's write it:
If Me.InitialTraining is Null Then
Blabla
End If

VBA returns me an error on the line "Me.InitialTraining si Null"

I dont get it, especially because when i write stuff like "If
Me.InitialTraining > Date..." it works fine.

Please help me guys!!! I am getting bold!!!!!!!
Alec

If IsNull(Me!InitialTraining) Then
 
Back
Top