PC User
Registered User.
- Local time
- Today, 11:10
- Joined
- Jul 28, 2002
- Messages
- 193
I'm trying to sort by clicking on the label in the header of a continuous subform list, but I'm getting an error saying that the recordsource is locked. I haven't encountered this type of error before. Usually I can change the recordsource while the form or subform is open. Does anyone have any ideas on how to resolve this?
Code:
Private Function SortOrder(col As String, xorder As String) As Integer
On Error GoTo Whoops
strSelect = "SELECT DISTINCTROW JournalSortId, ColumnDesc, ColumnName, SortDirection "
strFrom = "FROM tblJournalSort "
strOrderBy = "ORDER BY " & col & " " & xorder
strSQL = strSelect & strFrom & strOrderBy
Me.RecordSource = strSQL
Me.Form.Requery
OffRamp:
Exit Function
Whoops:
MsgBox "Error #" & Err & ": " & Err.Description
Resume OffRamp
End Function
Private Sub lblSortBy_Click()
Dim response As Integer
If strSortOrder = "DESC" Then
response = SortOrder("ColumnDesc", "Asc")
strSortOrder = "asc"
Else
response = SortOrder("ColumnDesc", "Desc")
strSortOrder = "DESC"
End If
End Sub
Private Sub lblDirection_Click()
Dim response As Integer
If strSortOrder = "DESC" Then
response = SortOrder("SortDirection", "Asc")
strSortOrder = "asc"
Else
response = SortOrder("SortDirection", "Desc")
strSortOrder = "DESC"
End If
End Sub