Can't setup Referential Integrity

%3CLINGO-SUB%20id%3D%22lingo-sub-2487321%22%20slang%3D%22en-US%22%3ECan't%20setup%20Referential%20Integrity%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2487321%22%20slang%3D%22en-US%22%3E%3CP%3EI%20created%20a%20DB%20with%20two%20tables%3A%3C%2FP%3E%3CP%3EProperty%20table%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BpropID%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bautonumber%20primary%20key%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Baddress%26nbsp%3B%20%26nbsp%3B%20short%20text%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bcity%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bshort%20text%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bstate%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bshort%20text%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResidents%20table%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20resID%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20autonumber%26nbsp%3B%20primary%20key%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20propID%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Blarge%20number%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3BnameLast%26nbsp%3B%20short%20text%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3BnameFirst%20short%20text%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20setup%20a%20one-many%20relationship%20between%20propID%20(Property%20table)%20and%20propID%20(Residents%20table).%3C%2FP%3E%3CP%3EBUT%20when%20I%20check%20the%20Referential%20Integrity%20checkbox%20in%20the%20dialog%20on%20the%20Relationships%20page%2C%20I%20get%20the%20following%20error%20%22Relationship%20must%20be%20on%20the%20same%20number%20of%20fields%20with%20the%20same%20data%20type.%22%3C%2FP%3E%3CP%3EBoth%20%22propID%22%20fields%20ARE%20the%20same%20data%20type.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20you%20set%20up%20Referential%20Integrity%26nbsp%3B%20(I%20never%20had%20this%20problem%20with%20earlier%20versions%20of%20Access)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2487321%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2487354%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20setup%20Referential%20Integrity%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2487354%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1088493%22%20target%3D%22_blank%22%3E%40lwoodsusa%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20post%20shows%20that%20the%20field%20called%20propID%20in%20the%20Residents%20table%20is%20a%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fusing-the-large-number-data-type-5b623f6e-641d-4e97-8bdf-b77bae076f70%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%22large%20number%22%3C%2FA%3E.%20Large%20Number%20is%20a%20different%20data%20type%20from%20%22Long%20Integer%22.%20The%20AutoNumber%20propID%20in%20the%20Property%20table%20is%20a%20Long%20Integer%2C%20not%20a%20Large%20Number.%20Change%20the%20datatype%20to%20Long%20Integer%20for%20that%20field%20in%20the%20Residents%20table.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I created a DB with two tables:

Property table

     propID     autonumber primary key

     address    short text

     city           short text

     state         short text

 

Residents table

    resID        autonumber  primary key

    propID     large number

   nameLast  short text

   nameFirst short text

 

I setup a one-many relationship between propID (Property table) and propID (Residents table).

BUT when I check the Referential Integrity checkbox in the dialog on the Relationships page, I get the following error "Relationship must be on the same number of fields with the same data type."

Both "propID" fields ARE the same data type.  

How do you set up Referential Integrity  (I never had this problem with earlier versions of Access)

7 Replies

@lwoodsusa 

Your post shows that the field called propID in the Residents table is a "large number". Large Number is a different data type from "Long Integer". The AutoNumber propID in the Property table is a Long Integer, not a Large Number. Change the datatype to Long Integer for that field in the Residents table.

 

@George Hepworth Thanks.  Yes, I know that the indexes are long integer but I haven't run into this "Large Number" so I took a guess---wrongly.

 

Thanks much.

 

Larry Woods

@lwoodsusa I'm glad you were able to sort it out.

 

The Large Number datatype was added for compatibility with SQL Server's BigInt datatype. If you have not worked with a SQL Server back end, though, it might not have been something you'd take note of.

 

Right you are. I come from the underworld of open software and (disgusting, I know) "MySQL!" ;)

Thanks, again.
Access does link to a wide variety of data sources, including SQL Server, MySQL, even Oracle, as well as SharePoint lists and even csv files. In other words, it's about as close to being data agnostic as it gets. I only worked with MySQL on one project, and an open source db product called "Firebird" one time in my career. They were challenging, but ultimately, it's part of expanding one's skill set.
One last question then I will leave you alone. I am just getting back into the MS game and wonder if the "free" version of SQL Server is still available, along with a reasonable set of tools? I would like to connect my Access app to SQL Server if possible but not prepared to pay the price of the full version.

@lwoodsusa 

Yes, SQL Server Express Download is free. SQL Server Management Studio is, IIRC, part of the package.

 

If you are more comfortable with MySQL, that is also a good option.