runtime error 2427.....

01-13-2004, 02:12 AM
Hi there! I'm having hard time solving this runtime error ("You entered an expression that has no value") Does anyone knows the solution? Any help would be greatly appreciated. Thanks!

Option Compare Database
'don't allow undeclared variables
Option Explicit
Public OldRes As String

Private Sub cboResDvr_AfterUpdate()

'activate the form
DoCmd.SelectObject acForm, "Resource Analysis"

'set ResDriver to value of bounded field in the referenced table
ResDriver = cboResDvr

'filter the query by the chosen BRUCode in BRUCont variable
'and ResDriver from the value of the control cboResDvr
DoCmd.ApplyFilter "Value Allocation Query" + ptl, "[BRUCode]='" + BRUCont + "' And " + "DrvCode='" + ResDriver + "'"

'refresh values of the form particularly the txtTotalSplit text box control

'check if splits are already present and flag user
If Not IsNull(Me.txtTotalSplit.Value) And Me.txtTotalSplit.Value <> 0 Then

MsgBox "You already have value for this resource.", vbOKOnly + vbInformation + vbApplicationModal, "Flag"

End If

'get focus away from txtTotalSplit to avoid edit by user

End Sub

01-13-2004, 06:51 AM

On what line does the code debug?
If on DoCmd.ApplyFilter.... , then could you
do the following

Dim sFilter As String
sFilter="Value Allocation Query" + ptl, "[BRUCode]='" + BRUCont + "' And " + "DrvCode='" + ResDriver + "'"

''output to the immediate window
Debug.Print sFilter
'-->try to see whether all parameters are in place.
DoCmd.ApplyFilter sFilter


01-13-2004, 06:57 PM
hi again! sorry..i forgot to highlight the error...nway, it's in:

If Not IsNull(Me.txtTotalSplit.Value) And Me.txtTotalSplit.Value <> 0 Then

The error says that "You entered an expression that has no value" What can I possibly do with it?


01-13-2004, 10:01 PM
You could probably try something like this :

If Nz(Me.txtTotalSplit.Value,0) <> 0 Then

The NZ function will check for you if it's NULL and replace it with the specified value (which is 0 in this case).

The problem is that VB can not properly evaluate your line of code if for example your value is really NULL. If you substitute Me.txtTotalSplit.Value by NULL, you would get something similar to this :

If Not IsNull() and <> 0 Then

And as you can see, this is not a correct sentence to evaluate.
Another way of doing it would be this way :

If Not IsNull(Me.txtTotalSplit.Value) Then
If Me.txtTotalSplit.Value <> 0 Then
(some code)
End If
End If

I prefer the first way, but it's all up to you. ;)
Hope that helps.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum