How to format a numeric field in Microsoft Access?

与世无争的帅哥 提交于 2019-12-25 06:14:32

问题


I want a numeric field to be always displayed as a 3-digit number. Padded left with 0s as needed.

Example: 3 is shown as 003, 24 as 024 and so on. Assuming max number is 999.

How do I do so? Thanks.


回答1:


Function Lpad (Value as String, PadCharacter as String, PaddedLength as Integer)
    Lpad = string(PaddedLength - Len(Value), PadCharacter) & Value
End Function

Ref.

Lpad("3", "0", 3)


来源:https://stackoverflow.com/questions/15456871/how-to-format-a-numeric-field-in-microsoft-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!