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:
The user must position the Recordset to the desired row before opening the Record object.
The Record object inherits the Recordset object's immediate or batch update mode. When in batch mode, the changes made to the Record object are submitted to the data source when the UpdateBatch method is called on the Recordset.
The Recordset object's Fields collection may be used to access the OriginalValue and UnderlyingValue properties of fields common to the Record and Recordset objects. However, there is no way to view these properties for fields that exist solely on the Record object.
CreateOptions cannot be used if the source is a Recordset object because it is not possible to create new rows directly in a Recordset.
The open Recordset may not reflect the new Record until the Recordset is closed and re-opened.
A run-time error occurs if the Recordset is positioned at BOF or EOF, does not contain rows, the underlying provider does not support Record objects, or CreateOptions is specified.
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