Hi MacDermott
Thank you for the quick response. And sorry for the lack of clarity
I'm using a downloaded function (written by Dieter Liessman at
www.topsolutions.de) called "LFSort" - Here's the code
'will amend the ORDER BY-part of a listbox's RowSource in order to have it sorted b
'the column(s) specified in strOrderField
Public Function LFSort(strRowSource As String, strOrderFields As String) As Strin
Dim intWhere As Intege
Dim intUpDown As Strin
If IsNull(strRowSource) Then GoTo end
intWhere = InStr(strRowSource, "DESC"
If intWhere <> 0 The
intUpDown = ";
Els
intUpDown = " DESC;
End I
intWhere = InStr(strRowSource, "Order By"
strRowSource = Left$(strRowSource, intWhere + 8
LFSort = strRowSource & strOrderFields & intUpDow
ende
End Functio
The event procedure looks like this
Private Sub cmdM1_Click(
'use Dieter's function to get a new ORDER BY-string / sort accordingl
lstBox.RowSource = LFSort(lstBox.RowSource, "M1"
'focus back on listbo
lstBox.SetFocu
End Su
"The routine did not work" means: When the command button for 'name' is clicked, the listbox re-sorts to the AutoNumberID of the records and not the alphabetical sort of the concantenated 'name' string I was expecting
For the 'name' column in the query, I had Installer:InstallerFirstName&" "&InstallerLastNam
For the event procedure, I had: (lstBox.RowSource, "Installer"
Now that I'm writing this down, it occurs to me to have InstallerFirstName and InstallerLastName in the query and set the listbox column width properties for those two columns to 0". That way the concantenated string is shown, and the function could use the appropriate rowsource (InstallerFirstName or InstallerLastName). That would solve my aesthetics problem, but not the question I posted..
----- MacDermott wrote: ----
I would expect a list sorted on a concatenated field to sort like this
Bob Jone
Bob Yate
Randy Jone
One sorted on Last Name then First Name would return this
Bob Jone
Randy Jone
Bob Yate
Is that what you're experiencing
("The routine did not work" doesn't give a lot to go on.
HT
- Turtl
Rick Willingham said:
I have a listbox built on a query. The listbox resorts when the use
clicks a command button placed at the top of each column. (e.g."Date"
"City", "State") I had a concantenated name ("first"&" "&"last") and th
sort routine did not work. Once I rebuilt the listbox to have separat
firstname and lastname columns and command buttons, then the routine worked