Solved

OrderByOn property of a form...

Posted on 1998-02-23
3
276 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

829 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