|
Question : Clear Orderby on exit of form
|
|
This seems like a simple question, but for the life of me i haven't been able to do this.
Here is the code on my search button that sorts my records when searching:
-----
Private Sub cmdSetSort_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim strSQL As String, intCounter As Integer 'Build strSQL String For intCounter = 1 To 6 If Me("cboSort" & intCounter) <> "" Then strSQL = strSQL & "[" & Me("cboSort" & intCounter) & "]" If Me("Chk" & intCounter) = True Then strSQL = strSQL & " DESC" End If strSQL = strSQL & ", " End If Next
If strSQL <> "" Then 'Strip Last Comma & Space strSQL = left(strSQL, (Len(strSQL) - 2)) 'Set the OrderBy property Forms![Timequery].OrderBy = strSQL Forms![Timequery].OrderByOn = True Else Forms![Timequery].OrderByOn = False End If End Sub
-----
(By the way, my search form are made up of unbound fields)
When I run this, it set's the OrderBy property on my form.
But when i go back into the form, the OrderBy property is still set to the previously sorted order, and it takes a year and a day to load the form.
How can i clear the OrderBy property, so everytime I enter this form it wont have the previously Sort order????
|
|
Answer : Clear Orderby on exit of form
|
|
try this
Private Sub Form_Unload(Cancel As Integer) Me.OrderBy = "" Me.OrderByOn = False End Sub
|
|
|
|