http://www.functionx.com/vbaccess/Lesson22.htm

Note: This is partial course about recordset. To get the entire course click the functionx logo!

Index Next

 

The Type of Recordset Objects

 

 

Creating a Recordset Object

 

 

Based on this, to programmatically create a Recordset object using the built-in library of Microsoft Access, you can start by declaring a variable of type Recordset. Here is an example:

Private Sub cmdRecordset_Click()
    ' Create a recordset
    Dim rst As Recordset
End Sub

This is essentially the same technique you use in DAO except that you must declare the variable as being of type DAO.Recordset.

To create a record set using ADO, start by declaring a variable of type ADODB.Recordset. Here is an example:

Private Sub cmdSetOfRecords_Click()
    Dim rstPersons As ADODB.Recordset
    
End Sub

 

Before using the record set, use the New operator to allocate memory for it. Here is an example:

Private Sub cmdSetOfRecords_Click()
    Dim rstPersons As ADODB.Recordset
    
    Set rstPersons = New ADODB.Recordset
End Sub

After declaring the variable, you must define the source of its records. Of course, you have various alternatives

The Recordset Object of an Object

 

In previous lessons, we saw that some controls, such as the combo box or the list box, were meant to hold a list of values. We also know that a form or a report is primarily created to show a record. Such controls hold their own record set. If you create a Recordset object and want to initialize it with the values held in the form where it is called, you can simply assign it Me.Recordset. Here is an example:

Private Sub cmdRecordset_Click()
    ' Create a recordset
    Dim rst As Recordset
    
    ' Specify that the record set points to the records of this form
    Set rst = Me.Recordset
End Sub

This means that, when a form is equipped to display the values of a list, that form has a Recordset object that represents its records. Once again, remember that there various other ways you can initialize a Recordset Object. For example, if you are using ADO, to use the records of the form that is calling it, you can assign Me.Recordset to your Recordset object. Here is an example:

Private Sub cmdSetOfRecords_Click()
    Dim rstPersons As ADODB.Recordset
    
    Set rstPersons = Me.Recordset
End Sub

 

Not: Benim burada anladigim kadariyla self feeding formlardan bahsediliyor. Ayni sanki combo box mantigiyla kendi verilerini iceren disariki tablodan veri almadan veri gosteren bir form mesela.

 

The Clone of a Form's Recordset

 

We saw that the Windows controls on a form could be used to display data from a table. This is done by specifying a list of values in the RecordSource property of the form. To get the set of records that the RecordSource property of a form holds, you can access its RecordsetClone property.

Not : Burada ise form`larin disaridan beslenmesinin yani tabloya bagli olmasini acikliyor