A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set Order by



 
 
Thread Tools Display Modes
  #1  
Old July 12th, 2004, 02:21 AM
Berny
external usenet poster
 
Posts: n/a
Default Set Order by

Can anyone tell me how to set the order by of a form when it opens?

I created a form with an order by; users change it and the form keeps the
new order which causes problems when the form is opened the next time in the
wrong order.


  #2  
Old July 12th, 2004, 02:35 AM
Jim Allensworth
external usenet poster
 
Posts: n/a
Default Set Order by

On Sun, 11 Jul 2004 21:21:40 -0400, "Berny"
wrote:

Can anyone tell me how to set the order by of a form when it opens?

I created a form with an order by; users change it and the form keeps the
new order which causes problems when the form is opened the next time in the
wrong order.


Assuming that your order is set in the Record Source, then just set
the OrderBy to an empty string. (By default Access keeps the last
order set)
Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = ""
End Sub

If you want to set an order on open.

Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = "SomeField"
Me.OrderByOn = True
End Sub

- Jim

  #3  
Old July 12th, 2004, 04:00 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default Set Order by

Are you allowing the users to change the *design* of the Form?

This is not recommended in fully developed databases.

--
HTH
Van T. Dinh
MVP (Access)


"Berny" wrote in message
...
Can anyone tell me how to set the order by of a form when it opens?

I created a form with an order by; users change it and the form keeps the
new order which causes problems when the form is opened the next time in

the
wrong order.




  #4  
Old July 12th, 2004, 04:07 AM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default Set Order by

"Van T. Dinh" wrote in
message
Are you allowing the users to change the *design* of the Form?

This is not recommended in fully developed databases.


"Berny" wrote in message
...
Can anyone tell me how to set the order by of a form when it opens?

I created a form with an order by; users change it and the form
keeps the new order which causes problems when the form is opened
the next time in the wrong order.


But Van, you can't stop the users from clicking the "Sort
Ascending/Descending" toolbar buttons unless you modify or replace that
toolbar. When they do that, the form's OrderBy property is set, and
saved when the form is closed. All you can do to prevent it is clear
that property or set it yourself when the form is opened.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #5  
Old July 12th, 2004, 05:03 PM
Marshall Barton
external usenet poster
 
Posts: n/a
Default Set Order by

"Van T. Dinh" wrote
Are you allowing the users to change the *design* of the Form?

This is not recommended in fully developed databases.


"Berny" wrote
Can anyone tell me how to set the order by of a form when it opens?

I created a form with an order by; users change it and the form
keeps the new order which causes problems when the form is opened
the next time in the wrong order.


Dirk Goldgar wrote:
But Van, you can't stop the users from clicking the "Sort
Ascending/Descending" toolbar buttons unless you modify or replace that
toolbar. When they do that, the form's OrderBy property is set, and
saved when the form is closed. All you can do to prevent it is clear
that property or set it yourself when the form is opened.



IMO, this is just about the most anoying "feature" ever
invented.

I **think** you can avoid the form save by providing a
command button that explicitly uses:
DoCmd.Close acForm, Me.Name, acSaveNo

I usually disable the form's Control and [X] Close buttons
on the title bar, but unless the main menu is customized, I
don't go so far as to disable its Close menu item.

--
Marsh
MVP [MS Access]
  #6  
Old July 13th, 2004, 01:51 PM
Berny
external usenet poster
 
Posts: n/a
Default Set Order by

Thank you

That was what I was looking for

"Jim Allensworth" wrote in message
...
On Sun, 11 Jul 2004 21:21:40 -0400, "Berny"
wrote:

Can anyone tell me how to set the order by of a form when it opens?

I created a form with an order by; users change it and the form keeps the
new order which causes problems when the form is opened the next time in
the
wrong order.


Assuming that your order is set in the Record Source, then just set
the OrderBy to an empty string. (By default Access keeps the last
order set)
Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = ""
End Sub

If you want to set an order on open.

Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = "SomeField"
Me.OrderByOn = True
End Sub

- Jim



  #7  
Old July 13th, 2004, 06:26 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default Set Order by

Thanks, Marsh.

acSaveNo is what I have used in the "Close" button. My users never
complained of this problem even those some of them use "Sort".

Will have to do some more test on this.

--
Cheers
Van T. Dinh
MVP (Access)


"Marshall Barton" wrote in message
...


IMO, this is just about the most anoying "feature" ever
invented.

I **think** you can avoid the form save by providing a
command button that explicitly uses:
DoCmd.Close acForm, Me.Name, acSaveNo

I usually disable the form's Control and [X] Close buttons
on the title bar, but unless the main menu is customized, I
don't go so far as to disable its Close menu item.

--
Marsh
MVP [MS Access]



  #8  
Old July 13th, 2004, 06:53 PM
Marshall Barton
external usenet poster
 
Posts: n/a
Default Set Order by

Van T. Dinh wrote:

Thanks, Marsh.

acSaveNo is what I have used in the "Close" button. My users never
complained of this problem even those some of them use "Sort".

Will have to do some more test on this.



Van,

Please let us know what your test's do or don't tell you. I
have been very curious about this issue ever since I had a
client that had their app made unusable because Access
somehow or other managed to save a filter/orderby that was
illegal (preventing the form from opening).

Makes me wish that MS had never invented this "feature".

I also have a nagging suspicion that Access isn't really
saving the entire form when it saves the Filter and OrderBy
properties, because the bloat issue might be pretty severe.
--
Marsh
MVP [MS Access]
  #9  
Old July 14th, 2004, 05:54 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default Set Order by

"Marshall Barton" wrote in message


Van,

Please let us know what your test's do or don't tell you. I
have been very curious about this issue ever since I had a
client that had their app made unusable because Access
somehow or other managed to save a filter/orderby that was
illegal (preventing the form from opening).


I had that happen because the client clicked the Save toolbar button,
thinking to save the record she'd been editing, after my code had opened
the form in Data Entry mode. She phoned me up to say "all my records
have disappeared!" My fault for giving her full menus.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong sort order of report's details section dsjohn_242 Setting Up & Running Reports 6 July 12th, 2004 10:21 PM
Inhereting the sort order Dan St.John Setting Up & Running Reports 1 July 9th, 2004 03:30 AM
2nd ORDER BY in form fields an General Discussion 1 June 25th, 2004 12:23 AM
Adding auto-numbered field screws up Table order Carl Database Design 5 May 30th, 2004 03:25 AM
X Axis Sort Order Jason Charts and Charting 2 October 9th, 2003 04:12 PM


All times are GMT +1. The time now is 07:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.