Share via

Microsoft Access 2007: error creating relationships

Anonymous
2016-10-06T16:44:07+00:00

When I try to create a relationship between my tables I get a message that says-

Relationship must be on the same number of fields with the same data types. (Error 3368)

The CONSTRAINT clause you are using to create a relationship includes a different number of fields for each table or includes fields with different data types. Check the number of fields in the CONSTRAINT clause, check the data types of fields to make sure they match, and try again.

 Why? How can I fix it?

How do I make them match so that I can link Customer ID (Primary Key) in one table 1 to my Customer ID (Foreign Key) in Table 2?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

ScottGem 68,830 Reputation points Volunteer Moderator
2016-10-06T17:33:12+00:00

So building on what Ken said, What DataType is the Customer ID in table 1 and what Datatype is the customerID in Table 2?

Note if you use an autonumber for the Primary key, then you need to use a Number>long Integer as the Foreign key.

Was this answer helpful?

9 people found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-10-06T16:59:44+00:00

    The problem here is most likely that the two columns are not of the same data type.  A CustomerID column as the primary key of a Customers table for instance will normally be an autonumber, which is just a special kind of long integer number column in which the values are inserted automatically.  Consequently the corresponding foreign key in an Orders table for instance will be a long integer number data type, but not an autonumber in this case.

    With primary and foreign keys columns like this there should be no difficulty in creating a relationship between the two tables.

    For future reference, when posting a question here, please give the question a title which more specifically identifies the problem, rather than merely calling it Microsoft Access 2007.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. ScottGem 68,830 Reputation points Volunteer Moderator
    2016-10-07T11:41:10+00:00

    The tutorials should say that the datatypes have to match. The problem is they don't all tell you that some datatypes have an underlying type. For example: a datetime field is really a Number>Double. And the aforementioned Autonumber is a Number>Long Integer underneath.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-10-06T19:16:27+00:00

    Thank you for your Help Scott.  None of the tutorials say anything about making the foreign key a Number Type field.

    My tables now have a relationship  :)  Thank you again.

    Was this answer helpful?

    0 comments No comments