Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 16th, 2006, 03:35 PM
Andrew W
Guest
 
Posts: n/a
Default Error in setting multiple field relationships with vba

I am trying to set up a relationship between three fields that make the
primary key of two tables. I am able to do this thru the Access
Relationships utility, but not thru VBA. I get the message: 'No unique
index found for the referenced field of the primary table". I've
checked the dataype and length of each of the three text fields that
make the primary key. It seems like Access is trying to make one part
of the relationship at a time. Any help will be appreciated.

Set db = OpenDatabase("g:\dataexport_2162006.mdb")

Set Rel = db.CreateRelation("Rel1")

With Rel
.Table = "tblSiteVisit"
.ForeignTable = "tblFieldSystems1"
'.Attributes = dbRelationUpdateCascade +
dbRelationDeleteCascade

'Set up the fields of the relation
Set Fld = .CreateField("site")
Fld.ForeignName = "site"
.Fields.Append Fld
End With

Set Rel = db.CreateRelation("Rel2")
With Rel
.Table = "tblSiteVisit"
.ForeignTable = "tblFieldSystems1"
'.Attributes = dbRelationUpdateCascade +
dbRelationDeleteCascade

'Set up the fields of the relation
Set Fld = .CreateField("technician")
Fld.ForeignName = "technician"
.Fields.Append Fld
End With

Set Rel = db.CreateRelation("Rel3")
With Rel
.Table = "tblSiteVisit"
.ForeignTable = "tblFieldSystems1"
'.Attributes = dbRelationUpdateCascade +
dbRelationDeleteCascade

'Set up the fields of the relation
Set Fld = .CreateField("sitevisitdate")
Fld.ForeignName = "sitevisitdate"
.Fields.Append Fld
End With
'Append the relation

db.Relations.Append Rel

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles