Wednesday, May 28, 2008

What to do when your relational database doesn't work

What do you do if you created your relational database without encountering any errors, but upon creating a query or report you get bad (e.g. empty) results?

Remember that relationships must be created between COMMON FIELDS. By that we mean that the fields must have
• the same field name (exactly the same, with no extra spaces, no missing 's', etc.) and
• the fields must be of the same data type (both must be number, both must be text, both must be date, and so on).



Most problems arise from errors when you create a relationship between two fields that are not truly common. Since you cannnot rename a field or change its data type while it is in a relationship, start your troubleshooting by deleting all relationships. Go to the relationship window, RIGHT-click very carefully with the tip of your cursor on a relationship line, then select the Delete option. Delete all relationships. Save the relationships window.


Now look at each table and check the fields that you want to relate.
Make sure that the field names are exactly the same.
Make sure that the data types are the same. Mismatched data types are the most common source of errors (often you will receive a message from Access reporting a "Type mismatch error").



When your corrections are made, create the relationships again, then the queries or reports based on the related tables.