Prev: Download and Convert online *.flv video to 3GP on Mac OS with YouTube converter
Next: Assigning permissions
From: John on 19 Mar 2010 06:08 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
From: Allen Browne on 19 Mar 2010 06:27 "John" <info(a)nospam.infovis.co.uk> wrote in message news:ub2ljw0xKHA.5480(a)TK2MSFTNGP06.phx.gbl... > 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").Required -- 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.
From: David W. Fenton on 19 Mar 2010 14:18
"Allen Browne" <AllenBrowne(a)SeeSig.Invalid> wrote in news:efyDV70xKHA.404(a)TK2MSFTNGP02.phx.gbl: > "John" <info(a)nospam.infovis.co.uk> wrote in message > news:ub2ljw0xKHA.5480(a)TK2MSFTNGP06.phx.gbl... >> 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/ |