Advertisement

06.04.2008 at 01:29PM PDT, ID: 23458253
[x]
Attachment Details

no unique index found for the referenced field of the primary table

Asked by ClaudeWalker in Access Coding/Macros, Microsoft Access Database

After a tireless amount of research and help from EE (Thank you).  I have gotten my normalization prototype almost finished.  I keep getting the "no unique index found for the referenced field of the primary table" error on the last line of my code where I try and create a relationship between my new created table and my modified table.

Thanks,
JOe K.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
CurrentDb.Execute "CREATE TABLE lstJobOrderType (JobOrderTypeID COUNTER, JobOrderType TEXT) "
                          
    CurrentDb.Execute "CREATE INDEX JobOrderTypeID ON lstJobOrderType (JobOrderTypeID) WITH PRIMARY"
    
    CurrentDb.Execute "INSERT INTO lstJobOrderType ( JobOrderType ) " & _
                      "SELECT DISTINCT WxMeasureDetails.MeasureName " & _
                      "FROM WxMeasureDetails " & _
                      "WHERE MeasureName <> '';"
           
    
    Dim db As DAO.Database
    Set db = CurrentDb
    Dim td As DAO.TableDef
    Dim tdFK As DAO.TableDef
    Dim rel As DAO.Relation
    Dim fld As DAO.Field
    
    Set td = db.TableDefs("WxMeasureDetails")
    td.Name = "tblJobOrder"
    
    Set td = db.TableDefs("tblJobOrder")
    td.Fields(0).Name = "JobOrderID"
    td.Fields(1).Name = "JobOrderTypeID"
    
    CurrentDb.Execute "UPDATE lstJobOrderType INNER JOIN tblJobOrder ON lstJobOrderType.JobOrderType = tblJobOrder.JobOrderTypeID SET tblJobOrder.JobOrderTypeID = [lstJobOrderType]![JobOrderTypeID];"
    
    CurrentDb.Execute "ALTER TABLE tblJobOrder ALTER COLUMN JobOrderTypeID INTEGER"
    
    Set tdFK = db.TableDefs("lstJobOrderType")
           
    Set rel = db.CreateRelation("JobOrder", td.Name, tdFK.Name, dbRelationUpdateCascade And dbRelationDeleteCascade)
    
    Set fld = rel.CreateField("JobOrderTypeID")
    
    fld.ForeignName = "JobOrderTypeID"
    
    rel.Fields.Append fld
 
    db.Relations.Append rel 'errors out here
[+][-]06.04.2008 at 01:32PM PDT, ID: 21713875

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 01:33PM PDT, ID: 21713886

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 01:34PM PDT, ID: 21713898

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 01:39PM PDT, ID: 21713936

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 01:40PM PDT, ID: 21713945

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 01:42PM PDT, ID: 21713959

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft Access Database
Sign Up Now!
Solution Provided By: jpipkins
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.04.2008 at 01:47PM PDT, ID: 21713996

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.04.2008 at 01:51PM PDT, ID: 21714032

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628