OrderBy property

  • Thread starter Thread starter tim s
  • Start date Start date
T

tim s

I have a form which displays a number of records, sorting
by either Name or ID (by changing the OrderBy property of
the form), depending which value is selected in an option
group.

The problem is, the form records should always sort by
Name when the form opens, but when I close the form when
it is sorted by ID, it opens up sorted by ID again,
because the OrderBy property still equals "ID".

If I change the OrderBy property to "NAME" On Open, the
form sorts by ID first, then the property is switched
to "NAME" and it sorts by name. So this works, except I
don't want it to first sort by "ID", as this takes 10
seconds or so.

Also, I've tried changing the value of OrderBy On Close
back to "NAME", but this actually re-sorts the records by
Name BEFORE the form closes, which I don't want it to do
(again the 10 seconds waiting).

Is there a way to change the OrderBy value without
actually ordering the records immediately, or is there
another solution to this problem?

Thanks for any help.

Tim
 
I had a similar problem and this solved it:

Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = "FieldToSortBy"
Me.OrderByOn = True
Me.Requery
End Sub
 
Back
Top