If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Setting PK as not nullable via code
Hi
I need to run through all table in the db and set the primary key in each as not nullable. How can I achieve this via code? Many Thanks Regards |
#2
|
|||
|
|||
Setting PK as not nullable via code
"John" wrote in message
... I need to run through all table in the db and set the primary key in each as not nullable. How can I achieve this via code? No need: if a field is (in) the primary key, it cannot be null. It is actually possible to set the Required property of the field to Yes using DAO code if you need to. Refer to: CurrentDb.TableDefs("MyTable").Fields("MyField").R equired -- 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. |
#3
|
|||
|
|||
Setting PK as not nullable via code
"Allen Browne" wrote in
: "John" wrote in message ... I need to run through all table in the db and set the primary key in each as not nullable. How can I achieve this via code? No need: if a field is (in) the primary key, it cannot be null. In your standard Jet/ACE table created via the Access UI, that is enforced by the index. I don't know if it's better to also set the Required property or not. I think the validation rule (or required property) fires before the check against the index, but I don't know if that has any impact on performance or locks or anything. -- David W. Fenton http://www.dfenton.com/ usenet at dfenton dot com http://www.dfenton.com/DFA/ |
Thread Tools | |
Display Modes | |
|
|