Link to home
Start Free TrialLog in
Avatar of keithcsl
keithcsl

asked on

OrderByOn property of a form...

hi

i have a form with several buttons to allow the user to sort the data, eg button 1 to sort by date.

i achieve this using:
  Forms("Order Form").OrderBy = "Order.[Date]"

whenever i reopen the form, the form remembers the previous OrderBy and performs the sort. my question is how do i prevent the sort when the form opens?

i know i need to use the OrderByOn property of the form but i am not sure when to set this porperty. i have tried setting it on the onOpen event but that didn't work because the sort would have started already.

keith
ASKER CERTIFIED SOLUTION
Avatar of guillems
guillems

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keithcsl
keithcsl

ASKER


i have tried the code and yes, it did prevent the sort. however, according to the help file, the onLoad event comes after the onOpen event. how would placing the OnOrderBy property on the onLoad prevent the sort?

then when i tried the code on the onOpen, it also prevented the sort. this means that i made a mistake in my question.

i have experimented more with this problem and found a better way to solve my problem. well, my form requires the user to exit the form via a button. before calling the docmd.close, i have the code

 me.orderbyon = false
 me.orderby = ""

this will erase any previous orderBy property, hence i do not have to check for it whenever i open the form. the only problem is that when the user clicks on the X button to close the form, i cannot insert my code before the onClose event. i can disable the X button but i would prefer not to. i'll be posting this new question later, so i am not expecting an answer from u. but any ideas and comments would be most appreciated.

Thanks
keith
There's a util form in the Neptuno database, that the form shows the all events. Check in this form, and you'll see all the events, because the help, is wrong in some aspects.

And thanks for the points.