|
-
Jun 8th, 2000, 06:42 AM
#1
Thread Starter
Addicted Member
Still trying to figure out how to sort descending with a dao recordset using the control, not sql.. can anyone help?
Thanks,
Thai
-
Jun 8th, 2000, 08:06 AM
#2
PowerPoster
Why not you use SQL Statement?
Why don't you use SQL statement in your RecordSource statement? 
What type of control you're using? Data Control?
Maybe you can do it like this:
Over here i use the Biblio.mdb database as my sample code.
I assume that you have add a DBGrid control and Data control in your form layout, and set the DBGrid DataSource to Data control.
Code:
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\Biblio.mdb"
'For Sorting the record base on the PubID Desc
Data1.RecordSource = "SELECT * FROM Publishers Order By PubID DESC;"
or
'For Sorting the record base on the PubID Asc
Data1.RecordSource = "SELECT * FROM Publishers Order By PubID ASC;"
Data1.Refresh
DBGrid1.Refresh
End Sub
-
Jun 8th, 2000, 08:57 AM
#3
Thread Starter
Addicted Member
I don't want to use SQL because the recordset has already been opened and I want to sort then refresh and have the recordset be sorted descending. That is why I specified in my previous post that I didn't need an sql example. I already know how to do it that way, I just need an example of how to do it with dao's recordset sort/attribute properties.
Thanks,
Thai
-
Jun 8th, 2000, 09:28 AM
#4
PowerPoster
Clone Recordset
Hi Thai how about the Clone recordset? But this may not be the best solution. 
Code:
Private Sub Form_Load()
Dim OrgDb As DAO.Database
Dim OrgRs As DAO.Recordset
Dim CloneRs As DAO.Recordset
Set OrgDb = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\Biblio.mdb", False, False)
Set OrgRs = OrgDb.OpenRecordset("SELECT * FROM Publishers ORDER BY PubID ASC;", dbOpenSnapshot)
Set CloneRs = OrgRs.Clone
CloneRs.MoveLast
While Not CloneRs.BOF
Debug.Print CloneRs.Fields(0)
CloneRs.MovePrevious
Wend
CloneRs.Close
Set CloneRs = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|