Disconnect | access | recordsets | data Meyyammai Subramanian
Microsoft Corporation
April 2001
Apply to:
Microsoft®access 2002
Summary: This article describes how to bind a data access page to a disconnected ADO recordset.
Directory
Brief introduction
To create a data access page that uses a disconnected set of records
Brief introduction
The disconnected recordset is an object in the client cache that does not connect to the server in real time. With disconnected recordsets, the ActiveX® data Object (ADO) allows you to create recordsets, disconnect from the data source, and enable users to view and edit the recordset offline.
For example, the category data access page asks whether the page should use disconnected data. If the user clicks Yes, the page prompts the user to enter the path of the disconnected recordset. If the user clicks No, the page uses live data.
To create a data access page that uses a disconnected set of records
Create a data access page in Design view.
Add the controls and grouping levels that you want. For example, create a Categories page that combines product records under different categories.
Add code to the BeforeInitialBind event to connect to a disconnected recordset, or to connect to real-time data.
The following is an example of the BeforeInitialBind event procedure.
<script language=vbscript Event=beforeinitialbind (info) for=msodsc>
<!--
Dim RS
Dim strShapeText
Dim strConnectionString
Dim strDataSource
Adopenkeyset=1
Adlockoptimistic=3
If Vbyes=msgbox ("Use disconnected recordset?"). ", vbYesNo) Then
On Error Resume Next
strDataSource = InputBox ("Please enter the _ to use
The path of the disconnected recordset. "," Enter Path ", _
"C:\Program Files\Microsoft Office\office10\samples\ _
Northwind.mdb ")
strShapeText = MSODSC. Rootrecordsetdefs (0). Shapetext
strConnectionString = "PROVIDER=MSDATASHAPE.1; _
Persist security Info=false;data source= "& strDataSource _
& "; User id=admin;data provider=microsoft.jet.oledb.4.0 "
Set rs = CreateObject ("ADODB.") Recordset ")
Rs. Open strShapeText, strConnectionString, adOpenKeyset, _
adLockOptimistic
If Err. Number <> 0 Then
MsgBox "Error:" & Err.Description & "Error" & Err.Number
End If
MSODSC. Setrootrecordset "Categories", RS
End If
-->
</SCRIPT>
Attention:
You cannot use a data access page that is bound to a disconnected recordset correctly from within Microsoft Access. You should open the page in Microsoft Internet Explorer to view it properly.
When you create a Visual basic®scripting Edition (VBScript) block of a Microsoft®office data source control (MSODSC) event, you must add the parameter to the event name, as follows:
<script language=vbscript FOR=MSODSC event=current (oventinfo) >
The oEventInfo parameter is used to return specific information about the event to the script. This parameter must be added regardless of whether this parameter is used or the script will not run.