
Error 3014: Can't open any more tables
I had the same problem, my solution is below - although this is more complex
than your requirements you might find it useful as it will accept any data
control and field no (from a grid head click event ) and sort remembering
the direction and reversing it each time.
In essence you need to use the refresh method on the data control before
using the openrecordset method.
Don't ask me why you need to do this though!
Public Sub SortGrid(DC As Data, ColIndex As Integer)
Dim Direction As String
DC.Refresh 'avoid error 3014
If ColIndex = Val(DC.Tag) Then
If InStr(DC.Tag, "DESC") Then
Direction = " ASC"
Else
Direction = " DESC"
End If
Else
Direction = " ASC"
End If
DC.Recordset.Sort = DC.Recordset.Fields(ColIndex).Name & Direction
Set DC.Recordset = DC.Recordset.OpenRecordset
DC.Tag = ColIndex & Direction 'remember settings
End Sub