2013-03-17 101 views
0

我想要一個數字字段始終顯示爲一個3位數字。根據需要填充0。如何在Microsoft Access中格式化數值字段?

示例:3顯示爲003,24顯示爲024等等。假設最大數量爲999.

我該怎麼做?謝謝。

+2

[指定自定義格式(http://office.microsoft.com/en-us/access-help/specify-how-data-displays-by-using-custom-formatting-HA010334645.aspx )。 – 2013-03-17 02:12:54

+0

謝謝。這是最簡單的。 – user776676 2013-03-17 02:17:12

+0

Robert Harvey引用的文章建議將格式添加到表格中。大多數情況下,表格中的格式是一個非常糟糕的主意。向格式和報告添加格式很好:http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/MSAccess/AccessVBAJetSQL/why-you-should-not-add – Fionnuala 2013-03-17 11:15:00

回答

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)