(Note: The information below is applicable to Access 2010 web databases. It may not be correct Access 2013 web apps. See the following link for further information: http://rogersaccessblog.blogspot.com/2013/12/access-web-databases-2010-vs-2013.html)
In this blog series, I'm discussing how to convert an existing Access application to a web application (the series starts here: How Can I Put My Access Database On The Web?).
As with any database project, I'm starting with the data. When I attempted to upload my existing tables into SharePoint, I got a number of errors (Uploading the Data to SharePoint). I dealt with some of them (primary keys and unique indexes) in my last post (How can I create a Compound Unique Index?). I'll finish up with the last of the errors: relationships.
Creating RelationshipsRelationships in SharePoint require the use of a Lookup Field. This is another feature that experienced developers have been railing against (see The Evils of Lookup Fields in Tables ) since it was introduced in Access 2000. Mostly, this is because Lookup Fields are used poorly. It may seem convenient to display a value other than the linked field, however if you are creating an application, it really does more harm than good. But, lookup fields don't have to be used to display a different field than the one that links the tables. You can also create a lookup field that actually displays the primary key value in the field rather than some other field. Doing so will remove the most egregious behavior of lookup fields, while still allowing you to use them to create relationships in SharePoint.
I still discourage their use in client systems (at least as far as displaying a value other than the one used to create the link), but they're necessary in web databases, so I've come to terms with them.
There are two ways to create Lookup fields: manually or with the Lookup Wizard. Most tutorials on web databases illustrate how do create a web database from scratch. In that case, the Lookup Wizard is the simplest way. It will walk you through all the steps necessary to create a proper relationship (with Referential Integrity) that will be acceptable to SharePoint.
However, this tutorial base on the premise you have an existing, client database with proper relationships already created that you want to convert into a web database. (Note: in this case, "client" means the database application runs in Access.) However, that's not enough to upload it to SharePoint. In addition to having a properly created relationship in Access, you MUST use a lookup field to upload it to SharePoint. If you've already got your relationships created and especially if you have data in your tables, it is far easier to create the lookup fields manually than to use the wizard.
Relationships must be created on the "many-side" or "child" table of a one-to-many relationship. As noted in the Relationship diagram above, the only child table is lnkBooksAuthors, and as a linking table, it is a child to both tblAuthors and tblBooks. Therefore, I need to go into each field and add the Lookup properties. I'll demonstrate it on AuthorID , however, BooksID would work the same.
To modify the AuthorID field, I open the lnkBooksAuthors table in design view, select the AuthorID field, and click the Lookup tab. It looks like this:
And create the following query:
Closing and Saving the Query Builder results in a Row Source of
SELECT tblAuthors.AuID FROM tblAuthors;
The only other change is I must make is to set the Limit To List property to Yes. The final result looks like this:
Because I've left the rest of the properties like the Bound Column and Column Count as they are, the result is a Lookup Field that displays the linking field.
After I do the same for every relationship in my database (which in this case is just the tblBooks/lnkBooksAuthors relationship), my database is ready to be uploaded to SharePoint, which is my next topic. (See Uploading To SharePoint).