Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error '94': Invalid use of Null

Status
Not open for further replies.

darkhat01

IS-IT--Management
Apr 13, 2006
144
US
Need some help on what I might be doing wrong? I tried to put a Error handler in it and it did not work. Currently the Error handler is commented out. From time to time there will not be a data and it will be Null. How can I tell it to skip this if there is a null???

Run-time error '94':
Invalid use of Null


Private Sub Form_Current()


'On Error GoTo ErrorHandler

If Me.NewRecord = True Then
Me!txtTarget.BackColor = RGB(190, 190, 255)
Me!txtTarget.Enabled = True
Me!txtComplete.Enabled = True

Else

If Year([TARGET_DATE]) < Year(Now()) Then 'Error is here
Me!txtTarget.Enabled = False
Me!txtComplete.Enabled = False
Else
Me!txtTarget.BackColor = RGB(255, 255, 255)
Me!txtTarget.Enabled = True
Me!txtComplete.Enabled = True
End If
End If

'ErrorHandler:
'Select Case Err.Number
' Case Is = 94
' Resume Next
' Case Else
'MsgBox Err.Number & " " & Err.Description
' Resume Next
'End Select

End Sub



Thanks,

Darkhat
 
Perhaps something like this ?
If Me.NewRecord Or IsNull([TARGET_DATE]) Then
Me!txtTarget.BackColor = RGB(190, 190, 255)
Me!txtTarget.Enabled = True
Me!txtComplete.Enabled = True
ElseIf Year([TARGET_DATE]) < Year(Now) Then
Me!txtTarget.Enabled = False
Me!txtComplete.Enabled = False
Else
Me!txtTarget.BackColor = RGB(255, 255, 255)
Me!txtTarget.Enabled = True
Me!txtComplete.Enabled = True
End If

The idea is to play with the IsNull function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Here is what I ended up with... Thanks PHV.... That was a great help... And it works now... I was able to play with the IsNull function.

Private Sub Form_Current()

If Me.NewRecord = True Then
Me!txtTarget.BackColor = RGB(190, 190, 255)
Me!txtTarget.Enabled = True
Me!txtComplete.Enabled = True

Else

If IsNull([TARGET_DATE]) Then
'Do nothing; Color cannot be assigned to a value that does not exist
Else
If Year([TARGET_DATE]) < Year(Now()) Then
Me!txtTarget.Enabled = False
Me!txtComplete.Enabled = False
Else
Me!txtTarget.BackColor = RGB(255, 255, 255)
Me!txtTarget.Enabled = True
Me!txtComplete.Enabled = True
End If
End If
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top