|
-
Nov 6th, 2006, 11:12 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Sort Recordset On Form
I have added the ability to search records on a form. I am trying to sort the results of the search by related field the search was conducted on, but I am having problems because the sort property doesn't seem to do anything.
VB Code:
Dim strDatabaseField As String
Dim intBookmark As Integer
If cboCriteriaField.text = "" Then
lblResults.Caption = "* Select A Search Criteria"
ElseIf txtSearch.text = "" Then
lblResults.Caption = "* Enter Search Text"
Else
'
' Save the information of before the query.
'
intBookmark = Data.Recordset.AbsolutePosition + 1
strDatabaseField = Replace(cboCriteriaField.text, " ", "")
Data.Recordset.Sort = strDatabaseField ' Sort the recordset before searching
Data.Recordset.FindFirst strDatabaseField & " LIKE '" & Sql(txtSearch.text) & "*'"
If Data.Recordset.NoMatch Then
'
' Restore the previous settings
'
Data.Recordset.Move intBookmark - 1
lblResults.Caption = "* No Matchs Found"
Else
lblResults.Caption = ""
txtSearch.text = ""
End If
End If
The initial recordset of the data control is to a single table using the following SQL.
VB Code:
Me.Data.RecordSource = "SELECT * FROM tblArchive"
Is there any reason the sort property isn't actually sorting anything?
-
Nov 6th, 2006, 01:27 PM
#2
Addicted Member
Re: Sort Recordset On Form
Is your recordset's property cursorlocation set to AdUseClient?
Maybe you must call recordset.moveFirst() before search !!
-
Nov 6th, 2006, 01:30 PM
#3
Re: Sort Recordset On Form
Sounds like your using the ADO Data control. Its a bound object and in VB 6 bound objects always give you more headaches then manually writting the code in pure ADO.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 6th, 2006, 01:51 PM
#4
Thread Starter
Fanatic Member
Re: Sort Recordset On Form
It is the ADO Data control. I will just write the code in pure ADO as you suggest Rob.
-
Nov 6th, 2006, 01:54 PM
#5
Re: [RESOLVED] Sort Recordset On Form
You have just saved yourself many headaches. 
If you need any help with ADO let us know.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|