Solved Relationship must be on the same number of fields and data type Error? (1 Viewer)

MsAccessNL

Member
Local time
Today, 05:59
Joined
Aug 27, 2022
Messages
184
I get this error when linking PK to Fk with referential integrity , Also with a newly created test db. It looks like my Access is corrupted, or am i missing something.

I noticed that that Access started numbering my databases again with nr 1 >> Database1

I am using Access2010

FielNumberError.PNG
 

Attachments

  • Test.accdb
    548 KB · Views: 77

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:59
Joined
Sep 12, 2006
Messages
15,658
So what data types are ID and ContactID?

I'm watching the tennis, so I can't inspect your database. Are they both numbers of the same size, integers or longs for example.
 

LarryE

Active member
Local time
Yesterday, 20:59
Joined
Aug 18, 2021
Messages
592
The ContactID field in the email table is set to Long Text Data Type. Set it to Number Data Type.
 

GPGeorge

Grover Park George
Local time
Yesterday, 20:59
Joined
Nov 25, 2004
Messages
1,877
I get this error when linking PK to Fk with referential integrity , Also with a newly created test db. It looks like my Access is corrupted, or am i missing something.

I noticed that that Access started numbering my databases again with nr 1 >> Database1

I am using Access2010

View attachment 108368
The error message is self-explanatory. Both fields in a relationship between two tables must be the same datatype. We assume that ID is an AutoNumber (since that's the most common approach). AutoNumbers are Long Integers. The Foreign Key to which you want to create the relationship, therefore, must also be a Long Integer.

The problem with proliferating, sequentially numbered copies of the accdb probably reflects failed Compact & Repair operations. Why that's happening would be hard to determine indirectly.
 

MsAccessNL

Member
Local time
Today, 05:59
Joined
Aug 27, 2022
Messages
184
thnx, george i am an experienced developer, no beginner. Both are number, access 2010 doesn’t has long integer as a seperate type.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:59
Joined
Feb 19, 2002
Messages
43,302
You didn't show us the definitions of the two fields in question. Also, your comment about "numbering" doesn't seem to relate to the error message.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:59
Joined
Feb 28, 2001
Messages
27,194
thnx, george i am an experienced developer, no beginner. Both are number, access 2010 doesn’t has long integer as a seperate type.

I have Ac2010 at home. It distinctly DOES have a LONG data type, which IS an integer.
 

MsAccessNL

Member
Local time
Today, 05:59
Joined
Aug 27, 2022
Messages
184
Thnx for the info, I haven’t and i have made many databases, neverhadyhis problem. Ithink something is corrupt.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:59
Joined
Feb 28, 2001
Messages
27,194
When I opened the DB you posted, the ID vs ContactID is doomed for RI because ContactID shows up on my Ac2010 as type MEMO whereas the ID field is an AutoNumber and is a Long Integer.

That ain't gonna fly.
 

GPGeorge

Grover Park George
Local time
Yesterday, 20:59
Joined
Nov 25, 2004
Messages
1,877
thnx, george i am an experienced developer, no beginner. Both are number, access 2010 doesn’t has long integer as a seperate type.
That should be verified please. I am pretty sure EVERY version of Access has a Long Integer datatype.;)
 

MsAccessNL

Member
Local time
Today, 05:59
Joined
Aug 27, 2022
Messages
184
I didn’t see that one, definitely some kind of corruption, mineis showing autonumber and number…
 
Last edited:

MsAccessNL

Member
Local time
Today, 05:59
Joined
Aug 27, 2022
Messages
184
I am afraid of loosing all mysettings and addins. Nobody encountered the same problem?
 

MsAccessNL

Member
Local time
Today, 05:59
Joined
Aug 27, 2022
Messages
184
Sorry guys, i have to appologize a thousend times. When i create a new table in Access, i select the number field as foreign key ( I have done this many many times), but in this db i encountered a lot of linking problems. I made a test db and encountered the same error. My mind was jumping to conclusions.

What had happened: In the original db the number field had been changeg into a Double field instead of long integer ( i don't know how), but anyway, in the test db I made the mistake te select a memo field and got the same error, but this time because of a different reason. A reason i did't see. I was sure i selected a number field!

I was going around in circles. Sorry for wasting your precious time...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:59
Joined
Feb 28, 2001
Messages
27,194
If only WE didn't make that same kind of selection errors as often as we do...

You are forgiven - for the crime of being totally human.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:59
Joined
Sep 12, 2006
Messages
15,658
thnx, george i am an experienced developer, no beginner. Both are number, access 2010 doesn’t has long integer as a seperate type.
Well it does. The general type is number, but then there are a number of alternatives from which you need to pick. Byte, integer, long,single, double etc. These have to match when making a relationship
 

Users who are viewing this thread

Top Bottom