473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Feb 16 '06 #1
0 1197

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christopher Harrison | last post by:
Is there a way to store an indefinite number of keys in one field and self join them? Imagine, for example, you have a table of users with a "friends" column. Say user 1 is friends with users 9, 7,...
2
by: Bodger | last post by:
Hi, Bearing in mind that I am new to this game, understand very little about SQL and don't work in IT, I was wondering if someone could give me some friendly advice on how to design...
0
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
by: Shannan Casteel via AccessMonster.com | last post by:
I have an invoice form with Parts and Labor as subforms. The parts section is based on a query that pulls data from 2 tables (tblParts & tblPartPerClaim) .. It has fields: ClaimID:...
19
by: Shwetabh | last post by:
Hi, I have two tables: Code and Color. The create command for them is : create table Color( Partnum varchar(10), Eng_Color char(10), Span_Color char(20), Frch_Color char(20), CONSTRAINT...
0
by: MLH | last post by:
I have a table, tblCorrespondence, that has been losing its KeyField setting. The field is named CorrespID and is an AutoNumber type field. This has happened in A97 on 3 occasions recently I...
2
by: LEX | last post by:
Could not update; currently locked by another session on this machine. Can someone help me figure out why access gives me this error on some record's memo fields but not on others?
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.