Combining Formula and Text question

C

codwilco

Pretty simple. Why does this work (="Dear "+[EmpName]+",") and this does
not(="Count: "+Count(EmployeeDetail!SSN))? The second returns #Error. And
yet, if I remove the text, the Count function works just fine. I just need
the two combined.

Thanks,
Dave
 
A

Allen Browne

Try an ampersand:
="Count: " & Count(EmployeeDetail!SSN)

The plus sign is ambiguous. It can mean concatenation (for text) or
summation (for numbers.) Your second example tries to combine a text and a
number, so Access got confused about which to do and errored out.

If you really want to use the plus, you could use Str() to force the number
to string:
="Count: " + Str(Count(EmployeeDetail!SSN))
 
L

Linq Adams via AccessMonster.com

Replace the plus sign (+) with an ampersand (&) in thesecond bit.

These are sometimes, but not always, interchangeable. I think Access can deal
with the plus sign here

="Dear "+[EmpName]+","

because you're obviously concatenating strings, but with

="Count: "+Count(EmployeeDetail!SSN)

it thinks you're actually trying to add

Count(EmployeeDetail!SSN)

which is an Integer to

"Count: "

which is a string.

You really should reserve the plus sign for math and the ampersand for
concatenation.
 
Top