I have a number of continuous forms where when the header label is clicked it sorts that column. Each column has its own sub, but I am getting more forms and would like to convert this to a Public Sub.
Here is sub for one column. The name of the control is txtClientName and the control source is ClientName.
When I call the Public Sub I can see the label change color and then back so that part works, but column does not sort. I am not getting any error messages. The column when loaded is not sorted on this column. The Public Sub resides in a separate module.
Thank you in advance.
You don't know what you don't know...
Here is sub for one column. The name of the control is txtClientName and the control source is ClientName.
Code:
Option Explicit
Const ClickColor As Long = 12957359
Const BaseColor As Long = 15790320
Sub lblSortClientName_Click()
lblSortClientName.BackColor = ClickColor
If Me.OrderBy = "ClientName" Then
Me.OrderBy = "ClientName DESC"
Else
Me.OrderBy = "ClientName"
End If
Me.OrderByOn = True
lblSortClientName.BackColor = BaseColor
End Sub
When I call the Public Sub I can see the label change color and then back so that part works, but column does not sort. I am not getting any error messages. The column when loaded is not sorted on this column. The Public Sub resides in a separate module.
Code:
Sub lblSortClientName_Click()
Call SortColumn("frmClientInfo", "lblSortClientName", "ClientName"
End Sub
Code:
Option Explicit
Const ClickColor As Long = 12957359
Const BaseColor As Long = 15790320
Public Sub SortColumn(ByVal frmName As String, lblName As String, colnName As String)
Forms(frmName).Controls(lblName).BackColor = ClickColor
If Forms(frmName).OrderBy = colnName Then
Forms(frmName).OrderBy = colnName & "DESC"
Else
Forms(frmName).OrderBy = colnName
End If
Forms(frmName).OrderBy = True
Forms(frmName).Controls(lblName).BackColor = BaseColor
End Sub
Thank you in advance.
You don't know what you don't know...