dbTalk Databases Forums  

A2K - auto changing the sort order of a subform

comp.databases.ms-access comp.databases.ms-access


Discuss A2K - auto changing the sort order of a subform in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
buckskin
 
Posts: n/a

Default A2K - auto changing the sort order of a subform - 12-18-2011 , 07:10 AM






I have a subform with various columns. At the top of each column there is a
button that the user can click to sort the form using the column field.

Clicking the button calls this function

Public Function SortForm(frm As Form, ByVal sOrderBy As String)
On Error GoTo Err_SortForm
'Purpose: Set a form's OrderBy to the string. Reverse if already set.
'Usage: Command button above a column in a continuous form:
' Call SortForm(Me, "MyField")

If Len(sOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If

Now when the user exits the form I make a note of which button was clicked
last.

Question - how do I make sure the form is sorted by that column when it
next opens?

Reply With Quote
  #2  
Old   
Bob Quintal
 
Posts: n/a

Default Re: A2K - auto changing the sort order of a subform - 12-18-2011 , 11:49 AM






"buckskin" <bucko (AT) mailinator (DOT) com> wrote in
news:9l672aF3gqU1 (AT) mid (DOT) individual.net:

Quote:
I have a subform with various columns. At the top of each column
there is a button that the user can click to sort the form using
the column field.

Clicking the button calls this function

Public Function SortForm(frm As Form, ByVal sOrderBy As String)
On Error GoTo Err_SortForm
'Purpose: Set a form's OrderBy to the string. Reverse if already
set. 'Usage: Command button above a column in a continuous
form: ' Call SortForm(Me, "MyField")

If Len(sOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If

Now when the user exits the form I make a note of which button was
clicked last.

Question - how do I make sure the form is sorted by that column
when it next opens?


Write the sort order variable to a table. Use the form's on load
event to query that table and load your variable from the table.


--
Bob Q.
PA is y I've altered my address.

Reply With Quote
  #3  
Old   
buckskin
 
Posts: n/a

Default Re: A2K - auto changing the sort order of a subform - 12-18-2011 , 11:52 AM



"Bob Quintal" <rquintal (AT) sPAmpatico (DOT) ca> wrote

Quote:
"buckskin" <bucko (AT) mailinator (DOT) com> wrote in
news:9l672aF3gqU1 (AT) mid (DOT) individual.net:

I have a subform with various columns. At the top of each column
there is a button that the user can click to sort the form using
the column field.

Clicking the button calls this function

Public Function SortForm(frm As Form, ByVal sOrderBy As String)
On Error GoTo Err_SortForm
'Purpose: Set a form's OrderBy to the string. Reverse if already
set. 'Usage: Command button above a column in a continuous
form: ' Call SortForm(Me, "MyField")

If Len(sOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If

Now when the user exits the form I make a note of which button was
clicked last.

Question - how do I make sure the form is sorted by that column
when it next opens?


Write the sort order variable to a table. Use the form's on load
event to query that table and load your variable from the table.
Thanks. So i'll need to modify my query using that value when it loads up.
I'll see if I can get that done.

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.