I have a continous form based on 1 table.
On the form I have a button that sets the OrderBy to as follows
DataSource = Me.RecordSource
If Me.OrderBy = DataSource & ".PaymentDate DESC" Then
Me.OrderBy = DataSource & ".PaymentDate"
Exit Sub
End If
Me.OrderBy = DataSource & ".PaymentDate DESC"
This works fine most of the time but sometimes clicking the button doesn't
sort the data. This usually happens after data has been added to the
underlying table and Requery has been run on the form. I can exit the form.
re-open it and click the up or down arrows once then my sort button will
work.
Any ideas on how to make the button work all time?
After setting the order, make sure OrderByOn is turned on:
Me.OrderByOn = True
Before it can change the sorting, Access has to save any edits that are in
progress. It is always a good idea to do this explicitly:
If Me.Dirty Then Me.Dirty = False

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I have a continous form based on 1 table.
> On the form I have a button that sets the OrderBy to as follows
[quoted text clipped - 15 lines]
>
> Any ideas on how to make the button work all time?