Programmatically Set the Primary Key of a table

  • Thread starter Antonio via AccessMonster.com
  • Start date
A

Antonio via AccessMonster.com

How do I Programmatically Set the Primary Key of a table?

I looped through all the properties of a table, and

all the properties of a field,

but cannot find a property "PrimaryKey"

I wanna set and un-set the PrimaryKey to be true or false, programmatically,
 
M

Marshall Barton

Antonio said:
How do I Programmatically Set the Primary Key of a table?

I looped through all the properties of a table, and

all the properties of a field,

but cannot find a property "PrimaryKey"

I wanna set and un-set the PrimaryKey to be true or false, programmatically,


Primary is not a property of the field object. It is a
property of the Index object. This is a very important
distinction, especially when you consider that a primary key
(or any index) can consist of up to ten fields.

Setting and unsetting this attribute is an ill advised thing
to do in almost all situations. Are you certain that it's
necessary to whatever you are trying to accomplish?
 
A

Antonio via AccessMonster.com

Thank you Marshall:

Yes, I am certain this is necessary. I have thought about it a lot. I'm
doing a conversion process to the table in question after importing it into a
new database, and the procedures I'm running require that a specific field be
NOT a Primary Key in order for the procedure to operate correctly.

Please help, thank you.

Marshall said:
How do I Programmatically Set the Primary Key of a table?
[quoted text clipped - 5 lines]
I wanna set and un-set the PrimaryKey to be true or false, programmatically,

Primary is not a property of the field object. It is a
property of the Index object. This is a very important
distinction, especially when you consider that a primary key
(or any index) can consist of up to ten fields.

Setting and unsetting this attribute is an ill advised thing
to do in almost all situations. Are you certain that it's
necessary to whatever you are trying to accomplish?
 
A

AnthonyK via AccessMonster.com

Thank you Marshall:

Nevermind; I figured it out. Thanks.

Marshall said:
How do I Programmatically Set the Primary Key of a table?
[quoted text clipped - 5 lines]
I wanna set and un-set the PrimaryKey to be true or false, programmatically,

Primary is not a property of the field object. It is a
property of the Index object. This is a very important
distinction, especially when you consider that a primary key
(or any index) can consist of up to ten fields.

Setting and unsetting this attribute is an ill advised thing
to do in almost all situations. Are you certain that it's
necessary to whatever you are trying to accomplish?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top