Click to See Complete Forum and Search --> : Create a primary key
How can I define a new primary key for my access 97 mdb
from a vb form code?
You can do this with SQL via an Execute statement (on your DAO database object or ADO connection object). You do it with either the 'CREATE TABLE' or 'ALTER TABLE' SQL statements using the 'CONSTRAINTS' clause. I suggest that you look up any or all of the above in the MS Access97 help because it's pretty clear there and far too much to write here! The only real trick is that you can name your constraints anything you want - as is illustrated by their examples.
You may need to use either a 'DROP' statement or an 'ALTER TABLE DROP CONSTRAINT' statement to get rid of an already existing PK before adding the new PK.
Good luck,
Paul
Patrice Bourdages
Oct 24th, 2000, 11:40 AM
I don't know about doing it on the fly, but at creation, have a look at this posting:
http://forums.vb-world.net/showthread.php?threadid=29119
Look for the last reply.
Patrice, are codes compatible with access97?
Patrice Bourdages
Oct 30th, 2000, 11:32 AM
Sorry for the delay... Didn't get any warning that a new message was posted...
I guess that it should work as well. I created Access97 and Access2000 MBD whitout a glitch.
Thanks, I tried it already.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.