Concatenating strings in a report

G

Guest

I am pretty new and I would like to concatenate two strings in an Access
report with some text in between. Would it go: [Field1] & "Text" & [Field2]
in the control source for a text box? It does not seem to work and I was just
wondering if I was doing something wrong?
 
A

Allen Browne

That looks fine, as long as you include the equal sign at the start, i.e.:
=[Field1] & " Text " & [Field2]

Make sure the Name of this text box is not the same as the name of any
fields. For example, it must not be called Field1 or Field2 if you have
those fields.

In some circumstances, the concatenation doesn't work unless you also put
text boxes on the report for Field1 and Field2. You can set their Visible
property to No so they don't show.
 
G

Guest

Awesome thanks guys, also I was wonderin if either of you knew if I could do
calculations in a text box? Because I have to convert a decimal to a percent
and I wondered if I should just do it in the box or somewhere else?

Allen Browne said:
That looks fine, as long as you include the equal sign at the start, i.e.:
=[Field1] & " Text " & [Field2]

Make sure the Name of this text box is not the same as the name of any
fields. For example, it must not be called Field1 or Field2 if you have
those fields.

In some circumstances, the concatenation doesn't work unless you also put
text boxes on the report for Field1 and Field2. You can set their Visible
property to No so they don't show.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

twen said:
I am pretty new and I would like to concatenate two strings in an Access
report with some text in between. Would it go: [Field1] & "Text" &
[Field2]
in the control source for a text box? It does not seem to work and I was
just
wondering if I was doing something wrong?
 
A

Allen Browne

Sure. Set the Control Source to:
=[Field1] / [Field2]
and set the Format property of the text box to:
Percent

Dividing by zero generates an error, so you might want to use:
=IIf([Field2]=0, Null, [Field1] / [Field2])

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

twen said:
Awesome thanks guys, also I was wonderin if either of you knew if I could
do
calculations in a text box? Because I have to convert a decimal to a
percent
and I wondered if I should just do it in the box or somewhere else?

Allen Browne said:
That looks fine, as long as you include the equal sign at the start,
i.e.:
=[Field1] & " Text " & [Field2]

Make sure the Name of this text box is not the same as the name of any
fields. For example, it must not be called Field1 or Field2 if you have
those fields.

In some circumstances, the concatenation doesn't work unless you also put
text boxes on the report for Field1 and Field2. You can set their Visible
property to No so they don't show.

twen said:
I am pretty new and I would like to concatenate two strings in an Access
report with some text in between. Would it go: [Field1] & "Text" &
[Field2]
in the control source for a text box? It does not seem to work and I
was
just
wondering if I was doing something wrong?
 

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