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?




Reply With Quote