I have this Access application where I pull in data from a SQL server database where the date is saved as a text field. I just created the ability for the users to sort the Recordset. It is very easy for text fields but now I want to be able to sort by date but unfortunately, as I said earlier it is saved as text in this format mm-dd-yyyy.
Here is the sort code I use:
Dim strSQL As String: strSQL = "exec Liab" & strQuearyName & " '" & strSearchValue & "%' "
'Dim qdf As QueryDef: Set qdf = CurrentDb.QueryDefs(strQuearyName)
With CurrentDb.QueryDefs(strQuearyName)
.SQL = strSQL
.ReturnsRecords = True
Set rst = .OpenRecordset
End With
'SortOutput rst
'rst.Sort = DateValue("DateOfLoss")
rst.Sort = Forms("SelectLiabilityClaimForm").cobSortBy
Set rstSorted = rst.OpenRecordset
With Forms("SelectLiabilityClaimForm").lstbxClaimList
'.RowSource = queryName
Set .Recordset = rstSorted
'.OrderBy = "claimantName"
.Requery
.SetFocus
End With
How can I sort by the text date, without having to change the passthrough query (I want that as a last resort)