Adding Field to Access db - need to make indexed property of field No Duplicates 
Author Message
 Adding Field to Access db - need to make indexed property of field No Duplicates

I have an autoincrementing field being added to a table in an Access db but
I also need to make the field so that it does not accept duplicates - which
falls under the Indexed property. I'm using ADOX 2.5 in VB6. Any help on
this will be greatly appreciated!


Mon, 15 Mar 2004 05:59:44 GMT  
 Adding Field to Access db - need to make indexed property of field No Duplicates

Quote:
> I have an autoincrementing field being added to a table in an Access db but
> I also need to make the field so that it does not accept duplicates - which
> falls under the Indexed property. I'm using ADOX 2.5 in VB6. Any help on
> this will be greatly appreciated!

Try creating a primary key for that field

' Create a new Primary Key for the table
Set oKey = New ADOX.Key
With oKey
    .Name = "PrimaryKey"
    .Type = adKeyPrimary
    .RelatedTable = "WebSite"
    .Columns.Append "WebSiteID"
End With
oCat.Tables("WebSite").Keys.Append  oKey

http://www.able-consulting.com/ADOX_Faq.htm#Q3

--

Thanks,
Carl Prothman
Microsoft Visual Basic MVP
http://www.able-consulting.com



Mon, 15 Mar 2004 06:27:53 GMT  
 Adding Field to Access db - need to make indexed property of field No Duplicates
I actually did try that already but I get an error and I'm not even sure
why. It might be because I wasn't setting up a table relationship
(RelatedTable) when I appended the column to the table, but I'm not sure. I
did try using adKeyUnique and it successfully added the column to the table
but it did not change the Indexed property to No Duplicates.


Quote:

> > I have an autoincrementing field being added to a table in an Access db
but
> > I also need to make the field so that it does not accept duplicates -
which
> > falls under the Indexed property. I'm using ADOX 2.5 in VB6. Any help on
> > this will be greatly appreciated!

> Try creating a primary key for that field

> ' Create a new Primary Key for the table
> Set oKey = New ADOX.Key
> With oKey
>     .Name = "PrimaryKey"
>     .Type = adKeyPrimary
>     .RelatedTable = "WebSite"
>     .Columns.Append "WebSiteID"
> End With
> oCat.Tables("WebSite").Keys.Append  oKey

> http://www.able-consulting.com/ADOX_Faq.htm#Q3

> --

> Thanks,
> Carl Prothman
> Microsoft Visual Basic MVP
> http://www.able-consulting.com



Mon, 15 Mar 2004 06:38:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. remove index from field or delete a indexed field

2. Create Index field in Access DB

3. need help opening a two field index with VB6 using access 2000

4. Help! Adding Field to Access DB.

5. Adding fields to an access db using VB3/Win

6. Adding Access DB Fields with VB6

7. Add field to Access DB

8. Adding Fields to Access 97 DB

9. Adding AutoNumber Fields to Access 97 DB

10. How to modified existing field and add new field in existing table for Access database

11. Newbie :( Need more room in field than Access DB allows

12. Need help reading Outlook keyword fields into Access field

 

 
Powered by phpBB® Forum Software