I've got two buttons in the header of my form, to allow the user to toggle the sort order via various fields. This first one below uses a single field and works fine. The second one however, uses two fields and does not work
The second code DOES sort the records by Surname then First Name ascending, but when I click it the second time it does nothing. Or presumably just sorts it ascending again. It won't sort it descending.
Have I got something wrong with the brackets, comma or quotes in this case? I realise I probably shouldn't have a space in the [First Name] field, but this is data that I'm linking to form a SharePoint list so i can't change this.
Thanks,
Pat
Code:
Private Sub cmdSortEmployer_Click()
Me.OrderByOn = True
If Me.OrderBy = "[Substantive Employer] DESC" Then
Me.OrderBy = "[Substantive Employer] ASC"
Else
Me.OrderBy = "[Substantive Employer] DESC"
End If
Me.Requery
End Sub
Code:
Private Sub cmdSortName_Click()
Me.OrderByOn = True
If Me.OrderBy = "[Surname],[First Name] DESC" Then
Me.OrderBy = "[Surname],[First Name] ASC"
Else
Me.OrderBy = "[Surname],[First Name] DESC"
End If
Me.Requery
End Sub
The second code DOES sort the records by Surname then First Name ascending, but when I click it the second time it does nothing. Or presumably just sorts it ascending again. It won't sort it descending.
Have I got something wrong with the brackets, comma or quotes in this case? I realise I probably shouldn't have a space in the [First Name] field, but this is data that I'm linking to form a SharePoint list so i can't change this.
Thanks,
Pat