Opening a Record Object Referencing an Open Recordset Object - Opening the Record Object after Opening the Recordset Object (Page 3 of 4 )
The record object has a number of properties and methods as shown in this extract from the Object Browser. These may be interrogated once the record is open.

The Record.Open () method has the following syntax as shown in the next picture. Not only it is possible to display the records, but you can also create files and folders.

Use the following code in another form’s button click event, or another button on the same form.
Private Sub Command0_Click()
‘Declare a recordset object
Dim rst As ADODB.Recordset
‘Declare a record object
Dim rec As ADODB.Record
‘instantiate the recordset
Set rst = New ADODB.Recordset
‘open the recordset
rst.Open "", "URL=http://hodentek/Atlas Website"
‘instantiate the record [Recordset is Open]
Set rec = New ADODB.Record
‘open the record
rec.Open rst
‘--------Interrogate Properties-----
Text1.SetFocus
Text1.Text = rec.ActiveConnection
Text5.SetFocus
Text5.Text = rec.Mode
Text7.SetFocus
Text7.Text = rec.ParentURL
Text9.SetFocus
Text9.Text = rec.RecordType
‘---end interrogation--
Set rst = Nothing
End Sub

The Mode and RecordType are returned as Enumerated constants, a basic feature of ADO. Mode: 1 refers to the constant adModeRead, the default, read only for the record open. The RecordType: 0 refers to the constant adSimpleRecord which means there are no child records. The ParentURL property is also read only. How many fields are there in this record and what are they?
To answer these questions you need to know how many fields there are in the record. This is easily done by including a calling of the the rec.Count property. Once you know this, you find the items collection in which each item is indexed and has a name and value by inserting the following code snippet before you close the record (between Text9.text and Set rst=nothing).
MsgBox (rec.Fields.Count)
For i = 0 To rec.Fields.Count – 1
Debug.Print rec.Fields (i).Name & " : " & rec.Fields (i).Value & vbCrLf
Next i
The Debug.Print statement copied from the immediate window is as follows:
RESOURCE_PARSENAME : Default.aspx
RESOURCE_PARENTNAME : http://hodentek/AtlasWebSite
RESOURCE_ABSOLUTEPARSENAME : http://hodentek/AtlasWebSite/Default.aspx
RESOURCE_ISHIDDEN :
RESOURCE_ISREADONLY :
RESOURCE_CONTENTTYPE :
RESOURCE_CONTENTCLASS :
RESOURCE_CONTENTLANGUAGE :
RESOURCE_CREATIONTIME :
RESOURCE_LASTACCESSTIME :
RESOURCE_LASTWRITETIME : 3/21/2006 4:06:42 PM
RESOURCE_STREAMSIZE : 924p
RESOURCE_ISCOLLECTION : False
RESOURCE_ISSTRUCTUREDDOCUMENT :
DEFAULT_DOCUMENT : http://hodentek/Default.htm;http://hodentek/
Default.asp;http://hodentek/index.htm;http://hodentek/iisstart.asp
RESOURCE_DISPLAYNAME : Default.aspx
RESOURCE_ISROOT : False
RESOURCE_ISMARKEDFOROFFLINE :
RESOURCE_METATAGS :
RESOURCE_LISTBASETYPE :
DAV:name : Default.aspx
DAV:parentname : http://hodentek/AtlasWebSite
DAV:displayname :
Default.aspx
DAV:isroot : False
DAV:getlastmodified : 3/21/2006 4:06:42 PM
DAV:getcontentlength : 924
DAV:iscollection : False
DAV:defaultdocument : http://hodentek/Default.htm;http://hodentek/
Default.asp;http://hodentek/index.htm;http://hodentek/iisstart.asp
These are standard fields returned by the OLE DB provider, in this case the Internet Publishing (MSDAIPP) provider. This list also contains the item RESOURCE_STREAMSIZE: 924, the size of the resource which may be retrieved using the Stream object.
Next: RecordType and Mode Properties >>
More Database Articles
More By Jayaram Krishnaswamy