ACC2002: Connection Property of the DSCEventInfo Object Does Not Work (295060)
The information in this article applies to:
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>
<!--
On Error Resume Next
Dim objConnection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb;"
If Err.number <> 0 Then
MsgBox "Error #" & Err.number & ": " & Err.description
Err.Clear
End If
-->
</SCRIPT>
- On the File menu, click Save, and on the File menu again, click Exit to return to Microsoft Access.
- 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 "Provider=SQLOLEDB.1;" & _
"Data Source=<ServerName>;" & _
"User ID=<UserName>;" & _
"Initial Catalog=<DatabaseName>"
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 "sa", and <DatabaseName> should be replaced by the name of the SQL Server or MSDE source, such as NorthwindCS.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. REFERENCESFor more information about the Connection property, click Microsoft Script Editor Help on the Help menu, type Connection Property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about the DSCEventInfo object, click Microsoft Script Editor Help on the Help menu, type DSCEventInfo in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 11/6/2003 |
---|
Keywords: | DAPScriptProb kbbug kbDAPScript kbdocerr kbdta kbnofix KB295060 |
---|
|