Text fields concatenation

G

Guest

I am parsing and rebulding a description field and supporting text fields
that vary quite frequently in content. I have already parsed out parts of the
description field into Desc1 and Desc2.

Here is what i have so far:
Desc9: [Desc1] & IIf([Size1]=Null,"",([Size1] & "x") &
IIf([Size2]=Null,"",([Size2]) & "x") & IIf([Wt1]=Null,"",([Wt1]) & "x") &
IIf([Wt2]=Null,"",([Wt2]) & "x") & [Desc2]).

Here is the result:
'"Gate long pattern, 2xxxx R.F. API 600 + B16.34, -, - ASTM A216 Gr. WCB,
150 Lbs, R.F. as per ASME B16.5, Serrated, Bolted Bonnet, Bolting : A193 Gr.
B7 / A194 Gr. 2H, Gask&Pack : Graph. / Graph. -, Stem : O.S. & Yoke,
Flexible Wedge, - Trim API 8, -, Ha.

What i want to be able to do is this:
If size 2 field is null, then just place a blank in this position of the
text field and do not place an "x".
If the size is not null, then place the size and an "x" aftrwards.
 
K

KML

Zachry,

Try this:

Desc9: [Desc1] & IIf(IsNull([Size1]),"",([Size1] & "x")) &
IIf(IsNull([Size2]),"",([Size2] & "x")) & IIf(IsNull([Wt1]),"",([Wt1] &
"x")) & IIf(IsNull([Wt2]),"",([Wt2] & "x")) & [Desc2]

You need to use IsNull() in VBA

Let me know if you need any more help...
 
B

BruceM

You can also use the + sign as a concatenation operator. If any part of the
expression within parentheses is null the entire expression within the
parentheses evaluates to null.
Desc9: [Desc1] & ([Size1] + "x") & ([Size2] + "x") & ([Wt1] + "x") & ([Wt2]
+ "x") & [Desc2]
 
G

Guest

KML, Bruce, thanks for the input, it worked fine...

KML said:
Zachry,

Try this:

Desc9: [Desc1] & IIf(IsNull([Size1]),"",([Size1] & "x")) &
IIf(IsNull([Size2]),"",([Size2] & "x")) & IIf(IsNull([Wt1]),"",([Wt1] &
"x")) & IIf(IsNull([Wt2]),"",([Wt2] & "x")) & [Desc2]

You need to use IsNull() in VBA

Let me know if you need any more help...
I am parsing and rebulding a description field and supporting text fields
that vary quite frequently in content. I have already parsed out parts of the
description field into Desc1 and Desc2.

Here is what i have so far:
Desc9: [Desc1] & IIf([Size1]=Null,"",([Size1] & "x") &
IIf([Size2]=Null,"",([Size2]) & "x") & IIf([Wt1]=Null,"",([Wt1]) & "x") &
IIf([Wt2]=Null,"",([Wt2]) & "x") & [Desc2]).

Here is the result:
'"Gate long pattern, 2xxxx R.F. API 600 + B16.34, -, - ASTM A216 Gr. WCB,
150 Lbs, R.F. as per ASME B16.5, Serrated, Bolted Bonnet, Bolting : A193 Gr.
B7 / A194 Gr. 2H, Gask&Pack : Graph. / Graph. -, Stem : O.S. & Yoke,
Flexible Wedge, - Trim API 8, -, Ha.

What i want to be able to do is this:
If size 2 field is null, then just place a blank in this position of the
text field and do not place an "x".
If the size is not null, then place the size and an "x" aftrwards.
 

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

Similar Threads

Parsing and Rearranging 4

Top