**#Error**

John M

Registered User.
Local time
Today, 15:31
Joined
Nov 20, 2001
Messages
69
I get "#error" in a field with control source .. =[sfmHireReturn].Form![HireTotBooks]. sfmHireReturn is a subform and the "#error" message is produced if I don't have anything in the subform. I have tried trapping for ISNull ([sfmHireReturn].Form![HireTotBooks]) but it doen't get rid of the problem.
 
In the On Current event of the form use code similar to this...

If IsNull(...) Then
'do nothing
Else
Me.MyField = Me.[sfmHireReturn].Form![HireTotBooks]
End if
 
Also, make sure that your textbox name is not the same as the field it is bound to. If it is, it will generate the #Error error as well.

BL
hth
:)
 
Not quite

Jack,

I haven't got it working yet.

The problem is that [sfmHireReturn].Form![HireTotBooks] gives me a "run time error 2427 you have entered an expression that has no value". Basically, [sfmHireReturn].Form![HireTotBooks] holds the number of books by totally the quantity in the subform. Because there is no books, there are no subforms and thus the "no value".

Can I try for no value like using a function i.e like IsNull??

Thanks.
 
I asssume that the subform is based on a query. You can use DCount to see if the query returns any records and if it does not then exit the code. Something like:

If DCount("*", "MyQuery") <=0 Then
Msgbox "No records to display"
Exit Sub
End If
 
Why didn't I think of that before??

Hi Jack,

DCount solved my problem. The funny this is - Why didn't I think of that before. You're a whiz!!!

Thanks.
 

Users who are viewing this thread

Back
Top Bottom