Results 1 to 7 of 7

Thread: Create a primary key

  1. #1
    Guest

    Exclamation

    How can I define a new primary key for my access 97 mdb
    from a vb form code?

  2. #2
    Guest

    Smile SQL

    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

  3. #3
    Guest
    Thanks Paul!

  4. #4
    Lively Member Patrice Bourdages's Avatar
    Join Date
    Jun 2000
    Location
    Quebec, Canada
    Posts
    83
    I don't know about doing it on the fly, but at creation, have a look at this posting:

    http://forums.vb-world.net/showthrea...threadid=29119

    Look for the last reply.

    Sincerely yours,

    Patrice B.
    Information System Analyst
    SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000

  5. #5
    Guest
    Patrice, are codes compatible with access97?

  6. #6
    Lively Member Patrice Bourdages's Avatar
    Join Date
    Jun 2000
    Location
    Quebec, Canada
    Posts
    83
    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.

    Sincerely yours,

    Patrice B.
    Information System Analyst
    SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000

  7. #7
    Guest
    Thanks, I tried it already.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width