Ok, that helps. I still have no idea where those
parenthesis are coming from, but I also don't know how you
could get anything by using a numeric format on a text
string. Try using:
=Format([txtCustTN1],"(@@@) @@@-@@@@") & (" / " +
[txtCustTN2]
You do need to verify that the table field, txtCustTN2, has
its AllowZeroLength property to No, because the above only
works if txtCustTN2 is Null when there is no phone number.
If that still causes trouble, try this:
=Format([txtCustTN1],"(@@@) @@@-@@@@") &
IIf(Nz([txtCustTN2], "") = "", "", " / " & [txtCustTN2])
I copied and pasted your expression and received an "invalid syntax" error.
In any case here is more info. The second telephone number field is not
required, only the first one but if there is a second number it needs to
appear on the report and the form. Both are text fields with a fixed length
of 15 characters. And no, the ( ) around the -22 is not a typo. That is
the resulting format when there is only one number being reported from the
txtCustTN1 field.
RayO wrote:
I am using "=Format([txtCustTN1],"(000) 000-0000") & " / " & [txtCustTN2]"
in a report to display the telephone number from two fields (txtCustTN1 and
txtCustTN2). It works fine as long as there are two numbers. My problem is
getting "txtCustTN1" to display properly when there is no "txtCustTN2." For
example, it will appear as "(383) 561(-22) 99 - /"
:
I have no idea where the ( ) around -22 could possibly come
from.
If that was just a typo, try using:
=Format([txtCustTN1],"(000) 000-0000") & (" / " +
[txtCustTN2])
which presumes that "no txtCustTN2" means that it is Null
If that doesn't take care of it, then please provide more
details about what is in those fields when they don't have a
phone number. Also need to know the phone number field type
in the table (Text, Long, ???).