Concatenate a string to a integer

D

Dave

In the control source of a textbox on a report, the following works fine:

="Investment: " & [Investment]

[Investment] field is of string data type.

However, when I try the same syntax with an integer data type, I get
"Error" displayed in the report's control.

Even if I try to convert to a string, like below, it still displays "error."

="Check No: " & str([CheckNo])

What am I doing wrong?
 
F

fredg

In the control source of a textbox on a report, the following works fine:

="Investment: " & [Investment]

[Investment] field is of string data type.

However, when I try the same syntax with an integer data type, I get
"Error" displayed in the report's control.

Even if I try to convert to a string, like below, it still displays "error."

="Check No: " & str([CheckNo])

What am I doing wrong?

1) The function to convert a number to a string is Cstr() not str().

2) There should not be a problem concatenating a number value with
text. I suspect you're getting an error because the name of the
control is the same as the field name in the expression, [CheckNo].
Change the control name, perhaps to txtCheckNo. If you always use an
unbound control when writing a control source expression you wont have
this problem in the future.

Note: if [CheckNo] is never going to be used in any calculation, it
would probably be best to change it to a text datatype field anyway.
 

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