using the "Order By" on a form...

B

Brad Pears

I have a situation where I have a form based on a query. The form displays
rows from this query. I would like the user to be able to simply click an
check box to change the sort order of the records being displayed there (I
am not using a listview control.) To do this now, depending on the option
selected, I change the recordsource to different query - where the query
selected has the appropriate sort order. This meant I had to create several
similar queries with only the sorting being changed...

I know this MUST be the long way. I tried simply setting the "Orderby"
property for the form but that did not do anything at all. Once you set that
orderby property, what command do you need to run to actually get it to
reorder based on that field? I tried refresh and that did nothing at all.
And, can you specify "ascending or descending" after the "orderby" field you
use?? (ie. me.orderby = "Date descending")

Here is sample code... (that did nothing)

if chkDateOrder then
me.orderby = "Date"
else if chkNameOrder then
me.orderby = "Name"
endif

'Now refresh
me.refresh

Any help would be most appreciated!

Thanks,

Brad
 
G

Guest

If chkDateOrder then
me.orderby = "Date"
me.orderbyon = True
else if chkNameOrder then
me.orderby = "Name"
me.orderbyon = True
endif
 
B

Brad Pears

great!! thanks!!!
Klatuu said:
If chkDateOrder then
me.orderby = "Date"
me.orderbyon = True
else if chkNameOrder then
me.orderby = "Name"
me.orderbyon = True
endif
 
B

Brad Pears

Well, I tried this and guess what - it still does not work!!! I even tried
placing the field in square brackets (i.e. me.orderby = "[Name]" and tried
placing the table/query name in fron too... me.orderby =
"[tablename].[name]"

Neither worked. So then I tried to issue a refresh afterwards... Still no
go. I just basically does not work...

Any other suggestions?

Thanks,

Brad
 
G

Guest

In your post, you put quotes around your orderby
me.orderby = "[Name]"
Did you try?
me.orderby = [Name]

Brad Pears said:
Well, I tried this and guess what - it still does not work!!! I even tried
placing the field in square brackets (i.e. me.orderby = "[Name]" and tried
placing the table/query name in fron too... me.orderby =
"[tablename].[name]"

Neither worked. So then I tried to issue a refresh afterwards... Still no
go. I just basically does not work...

Any other suggestions?

Thanks,

Brad

Klatuu said:
If chkDateOrder then
me.orderby = "Date"
me.orderbyon = True
else if chkNameOrder then
me.orderby = "Name"
me.orderbyon = True
endif
 
B

Brad Pears

I thought I tried that too but let me check... Thanks!
Klatuu said:
In your post, you put quotes around your orderby
me.orderby = "[Name]"
Did you try?
me.orderby = [Name]

Brad Pears said:
Well, I tried this and guess what - it still does not work!!! I even
tried
placing the field in square brackets (i.e. me.orderby = "[Name]" and
tried
placing the table/query name in fron too... me.orderby =
"[tablename].[name]"

Neither worked. So then I tried to issue a refresh afterwards... Still no
go. I just basically does not work...

Any other suggestions?

Thanks,

Brad

Klatuu said:
If chkDateOrder then
me.orderby = "Date"
me.orderbyon = True
else if chkNameOrder then
me.orderby = "Name"
me.orderbyon = True
endif


:

I have a situation where I have a form based on a query. The form
displays
rows from this query. I would like the user to be able to simply click
an
check box to change the sort order of the records being displayed
there
(I
am not using a listview control.) To do this now, depending on the
option
selected, I change the recordsource to different query - where the
query
selected has the appropriate sort order. This meant I had to create
several
similar queries with only the sorting being changed...

I know this MUST be the long way. I tried simply setting the "Orderby"
property for the form but that did not do anything at all. Once you
set
that
orderby property, what command do you need to run to actually get it
to
reorder based on that field? I tried refresh and that did nothing at
all.
And, can you specify "ascending or descending" after the "orderby"
field
you
use?? (ie. me.orderby = "Date descending")

Here is sample code... (that did nothing)

if chkDateOrder then
me.orderby = "Date"
else if chkNameOrder then
me.orderby = "Name"
endif

'Now refresh
me.refresh

Any help would be most appreciated!

Thanks,

Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top