MDAC 2.5 SDK - ADO


 

Open Method (ADO Record)

See Also    Example    Applies To

Opens an existing Record object, or creates a new file or directory.

Syntax

Open Source, ActiveConnection, Mode, CreateOptions, Options, UserName, Password

Parameters

Source   Optional. A Variant that represents the URL of the entity to be represented by this Record object, or a row of an open Recordset object.

ActiveConnection   Optional. A Variant that represents the connect string or open Connection object that specifies the file or directories (that is, the context) over which subsequent Record operations apply.

Mode   Optional. A ConnectModeEnum value, whose default value is adModeUnknown, that specifies the access mode for the resultant Record object.

CreateOptions   Optional. A RecordCreateOptionsEnum value, whose default value is adFailIfNotExists, that specifies whether an existing file or directory should be opened, or a new file or directory should be created. If set to the default value, the access mode is obtained from the Mode property.

Options   Optional. A RecordOpenOptionsEnum value, whose default value is adOpenRecordUnspecified, that specifies options for opening the Record. These values may be combined.

UserName   Optional. A String value that contains the user ID that, if needed, authorizes access to Source.

Password   Optional. A String value that contains the password that, if needed, verifies UserName.

Remarks

Source may be:

If the Record object represents an entity that cannot be accessed with a URL (for example, a row of a Recordset derived from a database), then the values of both the ParentURL property and the field accessed with the adRecordURL constant are null.

Usage

The following valid Open statements use the Web site, sample.microsoft.com, merely as an example of a URL.

In the first statement, the source is the URL of a folder. A Connection will be created implicitly from the URL.

Dim Record As ADODB.Record
Set Record = New ADODB.Record
Record.Open "http://sample.microsoft.com/myfolder/"

In the second statement, the source is a URL in the context of the given connection string. The "URL=" keyword specifies that the connection string is a URL.

Dim Record As ADODB.Record
Set Record = New ADODB.Record
Record.Open "mysubfolder", "URL=http://sample.microsoft.com/myfolder/"

In the third statement, the source is a relative URL in the context of the given, open Connection object.

Dim Connection As ADODB.Connection
Dim Record As ADODB.Record
Set Connection = New ADODB.Connection
Set Record = New ADODB.Record
Connection.Open "URL=http://sample.microsoft.com/myfolder/"
Record.Open "mydoc.doc", Connection

In the fourth statement, the source is a relative URL in the context of an open Record object that represents a directory.

Dim Record As ADODB.Record
Dim anotherRecord As ADODB.Record
Set Record = New ADODB.Record
Set anotherRecord = New ADODB.Record
anotherRecord.Open "http://sample.microsoft.com/myfolder/"
Record.Open "mydoc.doc", anotherRecord

In the fifth statement, the source is the current row of an open Recordset. When the URL keyword is used in the Connection parameter of the Recordset Open method, you should specify adCmdTableDirect in the Options parameter.

Dim Recordset As ADODB.Recordset
Set Recordset = New ADODB.Recordset
Recordset.Open "mydoc.doc", _
   "URL=http://sample.microsoft.com/myfolder/",,,adCmdTableDirect
Recordset.MoveLast() 
Record.Open Recordset