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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format numeric field with leading zeros and sign 1

Status
Not open for further replies.

ajv

IS-IT--Management
Jul 10, 2001
9
US
I would like to create a text file containing numeric fields with leading zeros and trailing sign. Any suggestions will be appreciated.

Thanks

ajv
 
Format([your field name],"0000")&"+"

This will format all numbers to 4 places. Add or remove the 0's in the quote marks to format to more or less places. Don't forget the quotes! Ex. 1, 10, 100 and 1000 will be 0001, 0010, 0100 and 1000.

Replace the plus sign with whatever sign you want.

Hillary
 
Thanks. I tried this as follows:
num2: IIf([num1]>0,Format([num1],"0000000") & "+",Format([num1],"0000000") & "-")

However if num1 is -3 I get -00000003-. Works great with positive numbers.

Thanks.
 
I'm assuming you don't want the first "-", you just want 0000003-.

What you have to do is take the absolute value of the number.

Try...
num2: IIf([num1]>0,Format([num1],"0000000") & "+",Format(Abs([num1]),"0000000") & "-")

Adding the Abs() around your [num1] will take the possitive value of the number but still allow the - at the end. I haven't tested this so I'm not sure if it will work.

Good luck!

Hillary
 
Works great!!. Thanks!!!

ajv
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top