rather than manually replacing "lblField1" in each procedure, how can I assign, say assign strFieldName, to the caption of the label that is clicked?
Are you saying that you want only one procedure regardless of which label is clicked? I don't know if this is possible, maybe someone else knows.
Add Public Cntr As Integer to the top of the form's code, after the Options.
Code:
Dim frm As Form
Set frm = Me
If Cntr = 0 Then
Call SortByLabel(frm, "lblField1", "")
Cntr = 1
Else
Call SortByLabel(frm, "lblField1, "DESC")
Cntr = 0
End If
And the global function:
Code:
Public Function SortByLabel(FormName As Form, LabelName As String, Desc As String)
FormName.OrderBy = LabelName & " " & Nz(Desc)
FormName.OrderByOn = True
FormName.Requery
End Function