Working with Sometimes Expressions that Sometimes have no value

H

halfbodyguy

Ok, i am using a math value which is supposed to equal 0 to fire a THEN
statement. All others fire the ELSE.

The problem Is, I am receiving the Value from a Subform, which in
certain instances has no value, because there is no data to build the
equation which we want to equal 0. So the question is: Is there a way
to declare how it should react if it does not have a value? Should I
maybe use an On Error response, or is there a simpler was to say If No
value?
 
G

Guest

If it has no value, that means it is returning a Null. There are a couple of
ways it can be handled. You could enclose the return value with the Nz
function and have it return some other value or you could explicitly check it
for Null

If IsnNull(Me.MySubForm.SomeControl) Then
'Do what you want for no value
ElseIf Me.MySubForm.SomeControl = 0 then


or

If Nz(Me.MySubForm.SomeControl, 0) Then

This means if the value returned by the control is Null, it will be
converted to a 0
You could use this if you want it to do the same as 0 or you could change
the 0 to another value so it would be evaluated as <> 0
 
H

halfbodyguy

Ok, I tried both. The idea is if it equals 0, then the Record is ok to
be allowed to be deleted. So i added

If IsNull([InVsOutSub]![Text3]) Then GoTo StartDelete

Where Startdelete is the beginning of the regular deletion sequence. It
still came back "Entered an Expression with no value" Because The
Text3 on the InvsOutsub comes up as a blank form, since there are no
records on the subform... Any thoughts?
 
H

halfbodyguy

Ok, I got it. I added an On Error command in the center, which catches
that error only, and pushes it to the right place... not sure if this
is bad coding, but it works beautifully.
 
G

Guest

Without seeing all your code, I can't tell where the error is occuring. It
would not be in the IsNull line because that is what the IsNull function is
for.
Is there some code in an [InVsOutSub]![Text3] event that could be the issue
or in your StartDelete routine?
(GoTo = Bad)
(Call = Good)
 
H

halfbodyguy

The Error that it is using is the Same error i was talking about. I put
an On error command in the exact place where it gives the error that
there is no value (for text3)... The issue is, when the subform
populates, it is blank, because there are no records. It is basically
receiving a record count of 0, and not even showing the subform, so
according to the code, the Text3 box does not even exist, therefore it
can't pull the information on it... I've never used the call
function... And what is wrong with using the On Error Goto? I'm not
justifying it, I am just trying find out if there is some sort of
official reason.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top