Sort Property Example

This example uses the Sort property to create a Dynaset with a specific sort order.

Dim Db As Database, Dn As Dynaset, I As Integer
Set Db = OpenDatabase("BIBLIO.MDB")      ' Open database.
Set Dn = Db.CreateDynaset("Publishers")  ' Create Dynaset.
Cls                                      ' Clear Form.
For I = 0 to 4                           ' Print 5 records.
  Print Dn.Fields("Name")
  Dn.MoveNext
Next I
Print                                    ' Print a blank line.
Dn.Sort = "Name Desc"                    ' Set Sort property.
Set Dn = Dn.CreateDynaset()              ' Recreate Dynaset.
For I = 0 to 4                           ' Print 5 records.
  Print Dn.Fields("Name")
  Dn.MoveNext
Next I