Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a unique field in a linked table

Status
Not open for further replies.

GerryGoldberg

Technical User
Apr 12, 2001
55
Using DAO, I am creating a secondary database where I would like to create a table which I can link to. Everything works fine except that Access asks me for the "Unique" field for this table. How can I set a field as "unique"
when I am creating it in the secondary database? Is "unique" a property that I can set for a field?

Thanks,

Gerry Goldberg

 
What are you doing when Access asks you for the unique field? I don't know if I've ever seen this message.

But to make a field unique, you have to create a unique index over it. With DAO, that means creating an Index object, appending a Field object to its Fields collection, and appending the Index to the TableDef's Indexes collection. Rick Sprague
 
GerryGoldberg:

Are you using a SQL "CREATE TABLE" statement, or are you manually going through the whole TableDef and Field creation?

If it's the SQL command to create it, then I think what you're missing, is your CONSTRAINT clause.

Check out the "CREATE TABLE" statement, under Access help, and it will tell you the details.

If you're using CreateTable and CreateField statements, then I think you need to be checking out the INDEX object and INDEXS object collection of the TableDef, which you can also find in help, and I think helps better at explaining those things than I am. 8O) If not, post a reply, and I'll try my best.

If you're using a totally different technique for creating your table, then let me know.

-MoGryph
[8O)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top