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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a form with a subform made f

Status
Not open for further replies.

wcj

Programmer
May 10, 2003
5
US
I have a form with a subform made from a query. I this form I have a text box with the below code as its control source. The variable in this function is an expression from the sub-form query. However whenever there is no data produced from this query I receive a runtime error #2427 ‘you have entered an expression that has no value.’ I receive this error even when I substitute the conditional “If genvar = NULL “ or “If genvar = “” “ and I always receive the same error. Can anyone tell me how to get around this problem?

Function func(genvar)
If genvar Then
func = genvar
Else
func = 0
End If
End Function
 
I would put in an ErrorHandler to trap the error. Modify your code as below, When access encounter error 2427, it just exits without bothering you

Function func(genvar)
On Error GoTo ErrorHandler

If genvar Then
func = genvar
Else
func = 0
End If

Exit_ ErrorHandler:
Exit Sub

ErrorHandler:
If Err.Number = 2427 Then ‘When encounter error 2427, just exit. . .
Exit Sub ‘or put in a function or sub to do whatever you want
Resume Exit_ ErrorHandler
Else
On Error GoTo 0 ‘catch other errors
End if

End Function
 
Thanks HomeAlone. That worked great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top