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?

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
= "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!! :)

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.

how do we put together all these codes?

Tom showed you the steps one might use to arrive at the final necessary expression...

Code:
`padl(ltrim(str(recno("workouts"),4)),4,"0")`
This is all you need.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•