You may find that this does not work in the query window, and you have to
execute it under ADO. Example:
strSql = "CREATE TABLE [MYTABLE] (MYFIELD DECIMAL(20,2) DEFAULT
100.75);"
CurrentProject.Connection.Execute strSql
You probably need to know that Access is incapable of handling fields of
type Decimal correctly. Details in:
Incorrect Sorting (Decimal fields)
at:
http://members.iinet.net.au/~allenbrowne/bug-08.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"AA2e72E" <AA2...@discussions.microsoft.com> wrote in message
news:E0028886-1979-48CD...@microsoft.com...
Use DAO, like this:
CurrentDb().TableDefs("MyTable").Fields("MyField").ValidationRule =
"Between 1 and 100"
For this particular property, you could also use ADOX to set the "Jet
OLEDB:Column Validation Rule" Property of the Column in the Table in the
Catalog. However, ADOX is incomplete, inconsistent between versions, buggy,
and subject to reference problems so we use it only where we are absolutely
forced to.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"AA2e72E" <AA2...@discussions.microsoft.com> wrote in message
news:79A0DC44-895E-4A2E...@microsoft.com...
> Thanks Allen. That works and it does populate the Default field in Design
> View.
> How do you set the Validation Rule?
>
>
> "Allen Browne" wrote:
>
>> In JET 4 (Access 2000 and later), you can use the DEFAULT keyword to
>> specify
>> a literal value (but not a function AFAIK).
>>
>> You may find that this does not work in the query window, and you have to
>> execute it under ADO. Example:
>> strSql = "CREATE TABLE [MYTABLE] (MYFIELD DECIMAL(20,2) DEFAULT
>> 100.75);"
>> CurrentProject.Connection.Execute strSql
>>
>> You probably need to know that Access is incapable of handling fields of
>> type Decimal correctly. Details in:
>> Incorrect Sorting (Decimal fields)
>> at:
>> http://members.iinet.net.au/~allenbrowne/bug-08.html
>>
>>