This past week I began exploring some of the capabilities in the new Access Web Database template. This template allows you to create a no-code database and upload it to a SharePoint 2010 server — thus allowing business users to quickly create and host small databases for business related tasks.
My first task was to create a data macro that would add a new user to the database when the published web database is visited the first time. Additionally, each return I would like to capture the number of times the user visited and when they visited the site last.
In order to capture this information I created a table named Users that included the columns UserLogin, UserWebID, UserDisplayName, UserEmailAddress, FirstVisitDate, LastVisitDate, TotalVisits. I created a data macro that would handle the add/update procedure (more in a later blog post) and then set my default form to update the user when the form is loaded.
I needed a way to get the information about the user — and Access did not disappoint. Making use of the CurrentWebUser method, I can obtain information about the user; however, the method requires a parameter — this is an enumeration that took some time to locate, so here is a link to the documentation on MSDN.
|acWebUserEmail||3||The current user’s e-mail address.|
|acWebUserID||0||The current user’s member ID.|
|acWebUserLoginName||2||The current user’s login name.|
|acWebUserName||1||The current user’s display name.|
Knowing the enumeration helps when I need to use this information to create a new user in my database — and I can use the user’s email address with another data macro to send them a welcome email when they first visit the site!