4. Linking Access to SQL Server

Using SQL Server as the relational database system for the HLU Tool will provide performance, reliability and volume benefits over Microsoft Access. But if some of the users don’t have authority to use SQL Server’s Management Studio (SSMS), or aren’t familiar with using SSMS, then one solution is to create an Access database front-end and link it to the HLU Tool database in SQL Server.

Many users will be more familiar with Access, so linking Access to SQL Server in this way allows users to view and edit the HLU Tool data without needing authority to use SSMS and without any risk of altering the database structure or settings. Using Access as a front-end to the database in this way also allows users to create and share Access queries, forms and reports specific to their needs.

Note

Database administrators need to ensure that users of the Access database have the necessary permissions to view and edit the data tables on the target SQL Server database.

4.1. Linking a new Access database

The process of linking an Access database to a SQL Server database can be complex and necessitates that you know the connection settings for the target database. The following instructions describe how to link to an existing installation of the HLU Tool database running on SQL Server. It should not matter which version (i.e. SQL Server or SQL Server Express) is installed or which release, as long as it is meets the System Requirements.

Note

It is also possible to link the exporter database to other relational databases, such as PostGIS, but instructions for this are not provided in this guide.

The following instructions describe how to link an Access database to a SQL Server database:

  1. Make sure your SQL Server service is running and the HLU Tool database is attached.

  2. Open the destination Access database in which you wish to create the linked tables.

  3. On the ‘External Data’ tab, in the ‘Import & Link’ group, click ODBC Database as shown in External Data tab.

    ../_images/AccessLinkExternalDataTab.png

    External Data tab

  1. Select Link to the data source by creating a linked table (as shown in Get External Data - OBDC Database dialog) and then click OK.

    ../_images/AccessLinkODBCDataDialog.png

    Get External Data - OBDC Database dialog

  1. In the ‘Select Data Source’ dialog box as shown in Select Data Source dialog, if the DSN file you want to use already exists, locate and select the DSN file. If you haven’t yet created a DSN file for the target database skip to Creating a new DSN file then continue from the next step.

    ../_images/AccessLinkSelectDataSourceDialog.png

    Select Data Source dialog

Note

If have haven’t already created a data source name (DSN) file for the HLU Tool database see Creating a new DSN file.

  1. Click OK. Access will display the ‘Link Tables’ dialog box as shown in Select Link Tables dialog.

    ../_images/AccessLinkSelectTablesDialog.png

    Select Link Tables dialog

  2. Under ‘Tables’, click each table that you want to link to, and then click OK.

Note

Many of the tables in the list are internal SQL Server tables. Do not select these - only select the HLU Tool export, data and lookup tables.

  1. If the ‘Select Unique Record Identifier’ dialog box appears, Access was unable to determine which field or fields uniquely identify each row of the source data. In this case, select the field or combination of fields that is unique for each row, and then click OK. If you are not sure, check with the SQL Server database administrator.

  1. If the link is successful Access will display the new linked tables in the Objects Navigation Pane as shown in Access Objects Navigation Pane.

    ../_images/AccessLinkObjectsNavigationPane.png

    Access Objects Navigation Pane

4.2. Creating a new DSN file

The following instructions describe how to create a new .dsn file for the HLU Tool database:

  1. Click New to create a new data source name (DSN) file. The ‘Create New Data Source’ wizard will start.

  2. Select SQL Server in the list of drivers (as shown in Create New Data Source - Select Driver dialog) and then click Next. If you are connecting to a different database then select the relevant driver.

    ../_images/AccessLinkSelectDriverDialog.png

    Create New Data Source - Select Driver dialog

  1. If you wish to enter the ‘Server Name’ and ‘Database Name’ at this stage click on Advanced… and enter them under the DRIVER keyword (see Create New Data Source - Advanced DSN dialog for example). Then click OK to return to the ‘Create New Data Source’ wizard.

    ../_images/AccessLinkAdvancedDSNDialog.png

    Create New Data Source - Advanced DSN dialog

    Note

    If you don’t enter the ‘Server Name’ and ‘Database Name’ here you will be prompted for them later.

  2. Click Next and then choose a suitable file path and file name for your new DSN. Then click Save.

  1. The file path and file name of the select DSN will be displayed (see Select Data Source dialog for example). Click Next.

    ../_images/AccessLinkSelectDSNDialog.png

    Select Data Source dialog

  2. A summary of the DSN settings will be shown (see ODBC Setup Summary dialog for example). Click Finish.

    ../_images/AccessLinkSummaryODBCDialog.png

    ODBC Setup Summary dialog

  1. If you didn’t enter the server and database names earlier you will be prompted for them now. Enter a description for the data source and then from the list choose which server you want to connect to (see Create New Data Source - Select Server dialog for example). Then click Next.

    ../_images/AccessLinkSelectServerDialog.png

    Create New Data Source - Select Server dialog

    Tip

    If the server doesn’t appear in the list then manually type the server name it into the Server field

  1. Choose either Windows NT authentication or SQL Server authentication, as shown in see Create New Data Source - Authentication dialog, depending on how the security settings have been defined in the SQL Server database then click Next. If you are not sure, check with the SQL Server database administrator.

    ../_images/AccessLinkSQLAuthenticationDialog.png

    Create New Data Source - Authentication dialog

  2. Select the ‘Change the default database to’ checkbox and then from the list select which database to connect to (see Create New Data Source - Select Database dialog for example). Then click Next.

    ../_images/AccessLinkSelectDatabaseDialog.png

    Create New Data Source - Select Database dialog

  3. Leave all the settings as the default values and click Finish.

  1. A summary of the ODBC Setup will be displayed (see Create New Data Source - Summary dialog for example). Click Test Data Source … to ensure the settings are correct and the connection works and then click OK to close the test window.

    ../_images/AccessLinkSummaryDialog.png

    Create New Data Source - Summary dialog

  2. Click OK to save the DSN. You will then be returned to the ‘Select Data Source’ window to continue linking a new database (see Linking a new Access database).

Note

Once you have defined a DSN for your HLU Tool database you won’t need to repeat steps 6 to 14 if you need to link another Access database in future.

4.3. Updating a linked table

Each time you open a linked table you will see the latest data displayed in it. However, structural changes made to a SQL Server table are not automatically reflected in a linked table. In this case you will need to update the linked table by applying the latest SQL Server object structure.

The following instructions describe how to update the links from an Access database to a SQL Server database:

  1. Make sure your SQL Server service is running and the HLU Tool database is attached.

  2. Open the destination Access database in which you wish to create the linked tables.

  3. On the ‘Database Tools’ menu click Linked Table Manager as shown in External Data tab.

    ../_images/AccessRelinkExternalDataTab.png

    External Data tab

  4. The ‘Linked Table Manager’ dialog will appear as shown in Linked Table Manager dialog.

    ../_images/AccessRelinkTableManagerDialog.png

    Linked Table Manager dialog

  1. Select the Always prompt for new location check box.

  2. Click the tables that you wish to update or click the Select All button (see Linked Table Manager selected tables for example) and then click OK.

    ../_images/AccessRelinkTableManagerSelectedDialog.png

    Linked Table Manager selected tables

  3. If the update if successful Access will display a message to that effect as shown in Linked Table Manager Success dialog. Otherwise Access will display an error message.

    ../_images/AccessRelinkSuccessDialog.png

    Linked Table Manager Success dialog

  4. Click OK to close the Linked Table Manager.