Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent! Help with "ToText" & formatting 2

Status
Not open for further replies.

itkyle

IS-IT--Management
Feb 13, 2002
31
0
0
US
I have 2 fields I need to combine - one is a text field, the other a currency field that must be converted to text, and then formatted to be exactly 10 characters long. I tried the following formula:

({BANK.BNK_NUM}+ToText({PAYMENT.CHK_NUM}),"0000000000",0)

It didn't work. I need to get this accomplished ASAP, so any help is GREATLY appreciated.

Kyle
 
Check the placement of your parenthesis...

({BANK.BNK_NUM}+ToText({PAYMENT.CHK_NUM}),"0000000000",0)
should be
({BANK.BNK_NUM}+ToText({PAYMENT.CHK_NUM},"0000000000",0))
 
The problem is that I want the bank number (BANK.BNK_NUM) to be included in that 10-character limitation, along with CHK_NUM. I need to combine BNK_NUM & CHK_NUM, then add leading zeros to make the total 10 digits.

Thanks for your help.
 
Try this..
Code:
dim x as number
dim tmpString as string
tmpString={BANK.BNK_NUM}+ToText({PAYMENT.CHK_NUM},0,"")
x=len(tmpString)
tmpString=replicatestring("0", x)&tmpString
formula=tmpString
 
I'm sorry, but I'm a relative newbie to this, using CR6. I know this doesn't go into a new formula field, but how do I insert that code into my report?

Thanks for your patience.
 
The formula above use the basic syntax,
since you have CR6, create a new formula and do this;

numbervar x;
stringvar tmpString;

tmpString :={BANK.BNK_NUM}+ToText({PAYMENT.CHK_NUM},0,"");
x :=10-len(tmpString);
tmpString :=replicatestring("0", x)&tmpString;

It's the same formula but using the crystal syntax.
The only thing is i don't know if the function "replicatestring" is available in CR6, let me know if this works.

HTH
Martin
 
Thanks for the assisst Martin. The syntax I posted above is VB and in version 8.5. Also, sorry I messed up alittle by missing
Code:
 10-len(tmpString)
, I'm not at work and I did it from memory. Let us know how it works out!
 
Works like a charm! The only things I had to change were "10-len" to "10-length..." and "&tmpstring" to "+tmpstring". You guys are awesome - thanks so much for the help!

Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top