sorting database 
Author Message
 sorting database

Ive successfully been able to produce a database with this code:

 datDisk.DatabaseName = "c:\program\Micros~2\samples\Diskonto.MDB"

    datDisk.RecordSource = "R?nta"
    datDisk.Refresh

    datDisk.Recordset.AddNew

    datDisk.Recordset("?r") = txt?r.Text
    datDisk.Recordset("M?nad") = TxtFM?n.Text
    datDisk.Recordset("Dag") = Txtdag.Text
    datDisk.Recordset("Diskonto") = TxtDisk.Text

BUT Id like to have it sorted.   The db consists of dates and
interestrates and I want to use it for calculation and want to have
the rows in dateorder.  I tried several ways of sorting, but with no
success.  Id appreciate any help.



Fri, 19 Mar 1999 03:00:00 GMT  
 sorting database

Quote:

> Ive successfully been able to produce a database with this code:

>  datDisk.DatabaseName = "c:\program\Micros~2\samples\Diskonto.MDB"

>     datDisk.RecordSource = "R?nta"
>     datDisk.Refresh

>     datDisk.Recordset.AddNew

>     datDisk.Recordset("?r") = txt?r.Text
>     datDisk.Recordset("M?nad") = TxtFM?n.Text
>     datDisk.Recordset("Dag") = Txtdag.Text
>     datDisk.Recordset("Diskonto") = TxtDisk.Text

> BUT Id like to have it sorted.   The db consists of dates and
> interestrates and I want to use it for calculation and want to have
> the rows in dateorder.  I tried several ways of sorting, but with no
> success.  Id appreciate any help.

The RecordSource property is capable of accepting SQL statements, for
example you could use the following:

        datDisk.RecordSource = "SELECT * FROM Ranta ORDER BY [Field Name]

Hope this helps.



Tue, 23 Mar 1999 03:00:00 GMT  
 sorting database

Quote:
>The db consists of dates and
>> interestrates and I want to use it for calculation and want to have
>> the rows in dateorder.  I tried several ways of sorting, but with no
>> success.  Id appreciate any help.

The table is always sorted by it's primary key, so just create a primary
key, and your sort is automatic.  If the dates are unique, just specifying
date as the primary key will work.  Otherwise date plus some other
variable(s) that will make it unique will do the trick
--
Bob Peticolas
Greenville, RI


Wed, 24 Mar 1999 03:00:00 GMT  
 sorting database

Quote:

> =
> I=B4ve successfully been able to produce a database with this code:
> =
>  datDisk.DatabaseName =3D "c:\program\Micros~2\samples\Diskonto.MDB"
> =
>     datDisk.RecordSource =3D "R=E4nta"
>     datDisk.Refresh
> =
>     datDisk.Recordset.AddNew
> =
>     datDisk.Recordset("=C5r") =3D txt=C5r.Text
>     datDisk.Recordset("M=E5nad") =3D TxtFM=E5n.Text
>     datDisk.Recordset("Dag") =3D Txtdag.Text
>     datDisk.Recordset("Diskonto") =3D TxtDisk.Text
> =
> BUT I=B4d like to have it sorted.   The db consists of dates and
> interestrates and I want to use it for calculation and want to have
> the rows in dateorder.  I tried several ways of sorting, but with no
> success.  I=B4d appreciate any help.

Mats,
        Instead of setting the RecordSource property of your data control to a
table (Ranta),
try setting to a valid SELECT statement with an ORDER BY clause:

        datDisk.RecordSource =3D "Select [field1], [field2], ... from Ranta ORDE=
R
BY [datefield]"

However, every time you add a new record you will need to REFRESH the
data control in order to keep the data control's recordset in the
correct order.

HTH...

Tom



Sun, 28 Mar 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Sorting Databases

2. Sort Database On Specific Field

3. Sorting Databases

4. Save a sorted database to disk?

5. How to sort database alfabetically in vb?

6. sorting database's using vb3 pro

7. Sorting database records

8. Sort Database On Specific Field

9. Sorting Databases

10. Save a sorted database to disk?

11. newbie: sorted database control

12. How do I sort databases, add tooltips, and add recent files to menus?

 

 
Powered by phpBB® Forum Software