Error message 97 (1 Viewer)

IainG

Registered User.
Local time
Today, 06:11
Joined
May 6, 2009
Messages
25
Runtime Error message 94

Can anyone help with the following?
I am trying to use the MONTH function within the following procedure but I get an 'Invalid use of Null' error when [StartDate] is blank!

Private Sub StartDate_AfterUpdate()
Dim aMonth As Integer

aMonth = Month([StartDate])

If aMonth = 0 Then WOW = WOW
If aMonth = 1 Or aMonth = 2 Then WOW = 0.6
End Sub
 
Last edited:

DCrake

Remembered
Local time
Today, 06:11
Joined
Jun 8, 2005
Messages
8,632
Try using the Nz() function as follows

Code:
aMonth = Month(Nz(Me.StartDate,0))

Or

Code:
If Not IsNull(Me.StartDate) Then
    Date Found
    Do something here
Else
    No Date Found
    Do something here
End If

David
 

IainG

Registered User.
Local time
Today, 06:11
Joined
May 6, 2009
Messages
25
David,

That works just fine.

Many thanks.

Iain.
 

Users who are viewing this thread

Top Bottom