Solved Relationship must be on the same number of fields and data type Error?

MsAccessNL

Member
Local time
Today, 18:28
Joined
Aug 27, 2022
Messages
204
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

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.
 
The ContactID field in the email table is set to Long Text Data Type. Set it to Number Data Type.
 
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.
 
thnx, george i am an experienced developer, no beginner. Both are number, access 2010 doesn’t has long integer as a seperate type.
 
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.
 
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.
 
Thnx for the info, I haven’t and i have made many databases, neverhadyhis problem. Ithink something is corrupt.
 
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.
 
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.;)
 
I didn’t see that one, definitely some kind of corruption, mineis showing autonumber and number…
 
Last edited:
I am afraid of loosing all mysettings and addins. Nobody encountered the same problem?
 
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...
 
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.
 
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

Back
Top Bottom