VBA IIf frustration

T

Tinius Olsen

Form inputs measurements normally in decimal format, into
table. This form has a button, to input occasional
fractional measurements, into this table.

Used the following, portion of button code, to accomplish
this:
DecVal = IIf(txtDenom = 0, txtInt, txtInt+
(txtNum/txtDenom))
Thought this would take care of those occasions there was
no fractional part.
If measurement is 3 3/16" this works fine and yields
3.1875 as it should, but if measurement is only 3",
rather then looking at the denominator part of the
fraction and seeing the zero letting DecVal equal only the
Integer, it errors out.

If I understand the VBA help this is because IIF always
evaluates both truepart and falsepart, even though it
returns only one of them.

Help how do I get around this ?
 

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