Table ActivitiesList has five fields: ActID (AutoNumber), ActName, ActAuthor, ActDateCreated, ActDateClosed, ActItemID.
Continuous form ActivitiesList displays table ActivitiesList data. The form header has command buttons cmdActivitiesAll and cmdActivitiesOpen.
Command button cmdActivitiesAll has this VBA code to display all activities:Code:Private Sub cmdActivitiesAll_Click() Me.RecordSource = "SELECT ActivitiesList.ActID, ActivitiesList.ActName, " & _ "ActivitiesList.ActAuthor, ActivitiesList.ActDateCreated, " & _ "ActivitiesList.ActItemID, ActivitiesList.ActDateClosed " & _ "FROM ActivitiesList " & _ "ORDER BY ActivitiesList.ActDateCreated DESC;" Me.Refresh End Sub
Command button cmdActivitiesOpen has this VBA code to display only open activities (activities whose ActDateClosed field is null):Code:Private Sub cmdActivitiesOpen_Click() Me.RecordSource = "SELECT ActivitiesList.ActID, ActivitiesList.ActName, " & _ "ActivitiesList.ActAuthor, ActivitiesList.ActDateCreated, " & _ "ActivitiesList.ActItemID, ActivitiesList.ActDateClosed " & _ "FROM ActivitiesList " & _ "WHERE (((ActivitiesList.ActDateClosed) Is Null)) " & _ "ORDER BY ActivitiesList.ActDateCreated DESC;" Me.Refresh End Sub
The form header has labels for each field -- lblActID, lblActName, lblActAuthor, etc. Clicking on a label will sort the form based on the selected field, either ascending or descending. Each label has VBA code similar to this code for lblActName:Code:Private Sub lblActName_Click() If OrderBy = "ActName" Then OrderBy = "ActName desc" Me.Refresh Else OrderBy = "ActName" Me.Refresh End If End Sub
So, after all that, here is my problem: When the form opens, the label sorting works as it should. Clicking either the cmdActivitiesAll or cmdActivitiesOpen button disables the label sorting. Label sorting is only reenabled by closing and reopening the form and functions only until one of the aforementioned command buttons is clicked.
What can I do to be able to use the cmdActivitiesAll and cmdActivitiesOpen buttons while keeping the label sorting working?
Thanks.
Steve