Solved

OrderByOn property of a form...

Posted on 1998-02-23
3
244 Views
Last Modified: 2008-03-04
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
0
Comment
Question by:keithcsl
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
guillems earned 20 total points
ID: 1969045
I use the event Load, to prevente the use of the order by

Private Sub Form_Load()
  Me.OrderByOn = False
End Sub

And when I want to use the order by, I have a button (in my test) to do:

Private Sub button1_Click()
  Me.OrderBy = "Order.[date]"
  Me.OrderByOn = True
End Sub

I hope that help you.
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1969046

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
0
 
LVL 3

Expert Comment

by:guillems
ID: 1969047
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.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now