• 08-24-2008, 01:06 AM
lkatz1
We want to run a update field with giving recno but we want it always 4 digit so recno 1 = 0001 how can we do it?
• 08-24-2008, 03:10 AM
MikeC
I do not believe it can be done as recno() is numeric and as far as I can tell, anytime a number has leading zeros they are automatically trimmed. Converting to character, however, makes it as easy as:

Code:

```dim x as c dim cnum as c cnum=1 x=padl(cnum,4,"0") ?x = "0001"```
If starting from numeric then use the str() function to first convert to character.

Only thing I can think of...maybe others will drop by and I will learn something new!! :)
• 08-24-2008, 08:01 AM
Tom Cone Jr
David,

The following expression can be used in a saved UPDATE OPERATION to assign each record's physical record number to a character type field in the same table. In this case the table being updated is called "Workouts".

Code:

`padl(ltrim(str(recno("workouts"),4)),4,"0")`
Interpreting this from the "innermost" function to the "outermost" function you can see that:

a) first the physical record number is obtained
Code:

`(recno("Workouts")`
b) then the physical record number is converted to character string of length 4
Code:

`(str(recno("workouts"),4)`
c) then the leading blanks in the new character string are trimmed off
Code:

`ltrim(str(recno("workouts"),4))`
d) and finally, the resulting string is padded on the left with leading zeros
Code:

`padl(ltrim(str(recno("workouts"),4)),4,"0")`
Check the help file discussion for an important warning about the use of the RECNO() function. It should not be used as an identifier for records in your table.
• 08-24-2008, 11:40 AM
lkatz1
`padl(ltrim(str(recno("workouts"),4)),4,"0")`