Dev Notes

Notes on Development with Microsoft Technologies

Getting User Information for Access Web Database

5 Comments

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.

Name Value Description
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!

Advertisements

Author: Chris Quick

I have been a developer of web based solutions since early 2001 delivering solutions to a wide array of organizations using ASP, ASP.NET and SharePoint. I was introduced to SharePoint in 2003 when the consulting firm I worked for at the time introduced it into the workplace. I began working with MOSS 2007 as soon as Microsoft released the RTM version in November 2006. The platform was implemented at the organization I worked for in 2007 and went live in March of that year. I was tasked with the administration and ongoing development of the platform. I currently work as a SharePoint Architect with Artis Consulting, developing solutions for a wide variety of business problems. The goal of this blog is to share my discoveries developing solutions with SharePoint. I welcome your comments and feedback to any post -- and I welcome suggestions for future topics.

5 thoughts on “Getting User Information for Access Web Database

  1. Hi,

    I am tasked with displaying a form that shows current users that are viewing the Web Access Database page and have no clue on how to go about it. Could you advise or show some pointers to this?

    Thanks.

  2. HI,
    I worked on access 2010 web data macros.When i uploaded to sahrepoint 2010 it’s is very slow.I want to know weather this backdrop and overcome in sharepoint server pack 1 or not.Please send to my mail about this.
    Thanks,
    MOHAMMAD SIDDIQALI

    • Usually, the first execution of a data macro will take a little longer. I have not tested under Service Pack 1 yet, but I would imagine this experience remains unchanged since the first execution is uncompiled code.

      • Chris,

        You were suppose to write a blog on how to Add/Update procedure on adding user information. I created a table with fields I want to capture and created a named macro with parameters as well as created a macro on load in the main page to run the data macro but it’s not fetching user information. Let me know if you have the solution and share it with me.

      • Rishi,

        After this post, I did not do any further work with Access Services and I apologize there was no follow-up. My current projects have had little need of Access Services so I do not know when I will be able to return to this topic. However, if you have a solution, feel free to post a follow-up comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s