Opening Published Databases Via Code

Access provides the OpenCurrentDatabase method to open a database, including databases that have been published to SharePoint or other types of websites. OpenCurrentDatabase is a member of the Application object and takes three parameters, two of which are optional. The following table describes those parameters.

Parameter Name

Parameter Description

filePath

The full name and path or URL string to the database to be opened. Required.

Exclusive

The Boolean value which determines whether the database should be opened in exclusive mode. Optional, and if not specified, the default value is False.

bstrPassword

The password string on the database that is to be opened. Optional, and if not specified, it is an empty string. If the database does have a password, the user is still prompted if this parameter is not passed through.

OpenCurrentDatabase can be useful for spawning another application via code. The following is one example of how a database can be opened from a SharePoint site:

Sub OpenDatabaseFromSite()

' Define variables

Dim accApp As New Access.Application

Sub OpenDatabaseFromSite()

' Define variables

Dim accApp As New Access.Application

' Open the database from the SharePoint site accApp.Visible = True accApp.OpenCurrentDatabase "http://MySharePointSite/Database.accdb" ' Clean up

Set accApp = Nothing End Sub

You can also perform that operation via code using the FollowHyperlink method. It's also a member of the Application object and takes a single parameter, which is the full URL to the page or other object to open. Here's an example of a subroutine to open a database using FollowHyperlink:

Sub FollowLinkToDatabase()

' Open the database from the SharePoint site

Application.FollowHyperlink "http://MySharePointSite/Database.accdb" End Sub

No matter which method you choose, Access is sure to make writing code to open a published database easy for you.

0 0

Post a comment

  • Receive news updates via email from this site