Create Table Field With Padding (1 Viewer)

PShiers

Registered User.
Local time
Today, 00:30
Joined
May 2, 2009
Messages
26
When you manually create a new field in a table it is possible in the properties section are to set field size e.g. Double, and the Format where it is possible specify padding e.g. '0000000000'. I want to be able to do this using SQL or VBA? I know how to use ALTER TABLE to create the field as a double, but how can I set the Format (padding) property in the table.

When searching for field format the result are all about using the format function, and not about how to alter a field property in an existing table, very frustrating

Any help would be very gratefully received.

Thanks
 

Minty

AWF VIP
Local time
Today, 01:30
Joined
Jul 26, 2013
Messages
10,366
Tables should only store the data, do any ancillary formatting you need either on the form or in the reports/queries as you need it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:30
Joined
Feb 28, 2001
Messages
27,138
Concur with Minty. The natural storage of anything other than strings is simply the raw number as represented in binary. Data CANNOT be stored as "padded" for things like DOUBLE, SINGLE, DATE, LONG, WORD, BYTE, INTEGER, and CURRENCY because they all have binary number formats. However, their "display" formats can certainly be adjusted. You can apply a display format to a field in a table, query, form, or report in order to make it have some particular appearance. Don't confuse saving something with showing something.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 20:30
Joined
Feb 19, 2002
Messages
43,223
If you need to store a code, store it as text. SSN is a code. Zip is a code, phone numbers are codes. At present, in the US they contain only numeric characters but that doesn't make them numeric data types. They are still strings and Zip codes in New England start with a zero which is problematic if you store zip as an integer.
 

Users who are viewing this thread

Top Bottom