Microsoft KB Archive/295060

= ACC2002: Connection Property of the DSCEventInfo Object Does Not Work =

Article ID: 295060

Article Last Modified on 11/6/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q295060



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
In the Help system for the Microsoft Script Editor, the Connection property of the DSCEventInfo object is described as a property that returns an ADO connection object. However, a variable set equal to this Connection property does not produce a connection object, and it can cause a run-time error.



RESOLUTION
Use standard ADO syntax to create the connection object. The following steps illustrate how to create a connection object.

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

 Start Access, and then open the sample database Northwind.mdb. Click Pages in the Database window, and then open the Employees page in Design view. On the Tools menu, point to Macro, and then click Microsoft Script Editor. In the Microsoft Script Editor, click the arrow in Object box, and then click MSODSC in the drop-down list. Click the arrow in the Event box, and then click DataPageComplete in the drop-down list to insert the DataPage Complete script event.  Modify the script event as follows: <SCRIPT event=DataPageComplete(objDSCEventInfo) for=MSODSC language=vbscript> </SCRIPT> </li> On the File menu, click Save, and on the File menu again, click Exit to return to Microsoft Access.</li>  On the View menu, click Page View. Note that the page opens as expected.

If you are using an Access project, you must change the objConnection.Open command line above to syntax similar to  objConnection.Open &quot;Provider=SQLOLEDB.1;&quot; & _ &quot;Data Source=<ServerName>;&quot; & _ &quot;User ID=<UserName>;&quot; & _ &quot;Initial Catalog=<DatabaseName>&quot; where <ServerName> should be replaced by the name of your SQL Server or MSDE computer, <UserName> should be replaced by a valid user account name, such as &quot;sa&quot;, and <DatabaseName> should be replaced by the name of the SQL Server or MSDE source, such as NorthwindCS. </li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

MORE INFORMATION
In the Help system for the Microsoft Script Editor, the Connection property of the DSCEventInfo object is described as follows:

Returns or sets the ADO Connection object used by the specified object. Read/write for the PivotTable object; read-only for the DataSourceControl and DSCEventInfo objects.

expression.Connection expression Required. An expression that returns one of the objects in the Applies To list (i.e. DSCEventInfo Object, DataSourceControl Object, PivotTable Object).

However, a variable that is set to the Connection property fails, usually silently, and can generate a run-time error when you try to use the connection object at some later point.

The following steps illustrate this behavior. Because the creation of the connection object fails silently, a user-defined error handler has been included to trap for the failure.

Steps to Reproduce the Behavior
<ol> Start Access, and then open the sample database Northwind.mdb.</li> Click Pages in the Database window, and then open the Employees page in Design view.</li> On the Tools menu, point to Macro, and click Microsoft Script Editor.</li> In the Microsoft Script Editor, click the arrow in Object box, and then click MSODSC in the drop-down list.</li> Click the arrow in the Event box, and then click DataPageComplete in the drop-down list to insert the DataPage Complete script event.</li>  Modify the script event as follows: <SCRIPT event=DataPageComplete(objDSCEventInfo) for=MSODSC language=vbscript> </SCRIPT> </li> On the File menu, click Save, and on the File menu again, click Exit to return to Microsoft Access.</li> On the View menu, click Page View. Note that you receive the following error message:

Error #424: Object required

</li></ol>

<div class="references_section">