Sorting an existing table through VB for Access

  • Thread starter Thread starter Dibster
  • Start date Start date
D

Dibster

Guest
Hello,

I really need some help in sorting a table that has been updated. The problem is that I am in a subform and am adding records to the table my subform is attached to (with Datasource) and my source table is not sorting after the updates. The added records are just appended to my source table. How can I ask for my table to sort (sql instruction or any VB command) through VB code? I am using Access 97 by the way.

Thank you in advance,
Alexandre Adib
 
Have you tried (after apppending the new data to the table of course) to open the table as a recordset then use the sort proerty on that recordset. for example:
'you must first create the recordset
dim mydb as CurrentDB
dim myrs as Recordset
'after the declarations you must define the
' recordset
set myrs = mydb.OpenRecordset ("table name")
'after defining the recordset open the
'recordset using the sort property
myrs.Sort = "Field you wish to sort by Asc or Desc"

That code will allow you to open the table using DAO as a recordset and apply to the recordser either an Assencding(Asc) or a Deseccnding (Desc) sort by the field you designate after you sort the recordset you may want to create a new table based on this recordset and write that table in the sorted order or you could write over the exsiting table
Your question is very interesting please let me know what route you take and how you solve your problem
good luck
JOHN
 

Users who are viewing this thread

Back
Top Bottom