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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary key not appending as unique

Status
Not open for further replies.

gwar2k1

Programmer
Apr 17, 2003
387
GB
hey, im working with a relational database and am currently trying to setup the relations. When the interpreter hits the line

Dbase.Relations.Append Rel

it says it hasnt found a unique primary key for the required table. Funny then that all the tables have unique primary keys. Im stumped, any one have a suggestion?

Code:
  Rem Sets the primary key
  Set Index = Tbl.CreateIndex("Primary Key")
  Set Fld = Index.CreateField("Order ID")
  Index.Fields.Append Fld
  Set Fld = Index.CreateField("Folder")
  Index.Fields.Append Fld
  Set Fld = Index.CreateField("EAN 8/13")
  Index.Fields.Append Fld
  Index.Primary = True
  Index.Unique = True
  Tbl.Indexes.Append Index
^-- Compound key in table CUSTOMERPRODUCT

Code:
Set Index = Tbl.CreateIndex("Primary Key")
  Set Fld = Index.CreateField("EAN 8/13")
  Index.Fields.Append Fld
  Index.Primary = True
  Index.Unique = True
  Tbl.Indexes.Append Index
^-- Single key in table PRODUCT

Code:
  Set Rel = Dbase.CreateRelation("1 to Many Product")
    Rel.Table = "CUSTOMERPRODUCT"
    Rel.ForeignTable = "PRODUCT"

  Set Fld = Rel.CreateField("EAN 8/13")
    Fld.ForeignName = "EAN 8/13"
    Rel.Fields.Append Fld
    
  [b]Dbase.Relations.Append Rel[/b]

  Set Rel = Dbase.CreateRelation("1 to Many Customer")
    Rel.Table = "CUSTOMERPRODUCT"
    Rel.ForeignTable = "CUSTOMER"

  Set Fld = Rel.CreateField("Folder")
    Fld.ForeignName = "Folder"
    Rel.Fields.Append Fld
    
  Dbase.Relations.Append Rel
^-- setting up the relations

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top