TESTING THE CONNECTIONS OF LINKED TABLES AT STARTUP

As you continue to examine the sections of the ap_AppInit() function, now look at section 3, which opens and tests the connection for one of the tables located in the back end, with the connection being a link in the front end.

'-- Section 3: Open the table containing the list of linked tables
Set dynSharedTables = dbLocal.OpenRecordset("tblSharedTables", _
   dbOpenDynaset)

On Error Resume Next

dynSharedTables.MoveLast
Set dynTestTable = dbLocal.OpenRecordset(dynSharedTables!TableName, _
     dbOpenDynaset)

intCurrError = Err.Number
strCurrError = Err.Description

Do Until intCurrError = 0

   On Error GoTo Error_ap_App_Init

   Select Case intCurrError
     Case apErrFileNotFound, apErrTableNotFound, _
          apErrPathNotValid, apErrDeviceNotAvlble

The code in section 3 performs these actions:

  1. The tblSharedTables table is opened and assigned to dynSharedTables, which is a recordset data type variable.

Note

tblSharedTables contains two Text-type fields: TableName and ExportFileName. Figure 26.8 shows what the table looks like in datasheet mode in the World Wide Video Application.

Figure 26.8. tblSharedTables is used for linking, unlinking, and exporting tables.



  1. The code sets error handling to ignore errors and just moves to the next line by using the On Error Resume Next statement.

  2. The code tries to open the first table in dynSharedTables as a dynaset, and then stores the error codes, if any, to variables for later use.

  3. The code begins a loop that performs another test (at the bottom), as in step 3. Inside this loop are the corrections for the various errors. When one error is solved—for example, a moved back end—the loop tests again and sends the code execution through the error list again.

  4. The code turns on error handling again and examines the possible errors that occurred. Constants are used to represent the errors that you want to look for.

The following table shows the error constants looked for in this section. All these errors can be handled by relinking the tables.

Constant Name Description of Problem
apErrFileNotFound The back-end database isn't found for the current path in the linked table.
apErrTableNotFound The current table listed in SystemTables isn't found in the front-end database.
apErrPathNotValid The path in the link is no longer valid, possibly because the network path has changed.
apErrDeviceNotAvlble The network might be down.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.23.3