Discussions

Expand all | Collapse all

Add leading zeros to Form ID # to make even length

  • 1.  Add leading zeros to Form ID # to make even length

     
    Posted 03-23-2017 15:46

    I am using the following formula to add leading zeros to a request # field I created on a form.

    "Request"&Right("000" & ToText([Record ID#]),5)

    I would like to limit the number of characters to 11 and have the leading zero's be consumed as the record id # increases.

    For example:

    "Request00012" should be "Request0012"

    Is there a way I can modify the field or form to do this?



  • 2.  RE: Add leading zeros to Form ID # to make even length

    Posted 03-23-2017 15:48
    Request"&Right("0000)" & ToText([Record ID#]),4)


  • 3.  RE: Add leading zeros to Form ID # to make even length

    Posted 03-23-2017 18:23
    You are going to have to account for growing numbers.

    Something like...
    If([Record ID#]>99, ...
    If([Record ID#]>999, ...
    If([Record ID#]>9999, ...
    etc.


  • 4.  RE: Add leading zeros to Form ID # to make even length

    Posted 03-23-2017 18:33
    Corrected formula

    "Request"&Right("0000" & ToText([Record ID#]),4)