Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change sort order by clicking on an option group button 1

Status
Not open for further replies.

KavJack

Programmer
Apr 1, 2001
46
I have a form which displays my 100+ records in a particular sort order based on a query. I want to incorporate a radio button (option group button) to select a particular sort order. Right now, I have two SQL queries which sort the same records in a different order. I have an option group control value which takes on the value 1 for a sort by division or 2 for a sort by alpha. How can I use this value to select which sort order I want so that when I scroll through the records on my form I see them in the order that I have selected ? Is it possible to dynamically generate the ORDER BY statement in the query or do I have to have two different queries ?
 
You dont need a separate query. What you want to do is to set the ORDERBY property for the form to the field [Alpha] or [Division] and set the ORDERBYON property to True.
This can be done in the AfterUpdate event for the option group. Don't set any sort order in the query itself. You probably will also want to set the default ORDERBY property in the form.

Does that help? Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
No, this answer doesn't help me. First of all, I am not doing any updating - just reading or searching for a record so I don't see why the AfterUpdate event gets invoked.
The option group button doesn't have an AfterUpdate eventcontrol feature listed. I want to be able to click on the radio button and select the sort order for my records.
This part of your answer : and set the ORDERBYON property to True. - I don't know how to do this. I looked at the help feature and it used this in the context of a Report not a Form. Maybe I could e*mail you a copy of my form and underlying records ?
 
The AfterUpdate event is for the option group itself, not the button. When you click on a button, the button changes, but so does the option group. The value of the option group becomes 1 or 2, causing an AfterUpdate for the option group.

You set the OrderByOn property with the following line:
Me.OrderByOn = True

If that doesn't help, I'll send you a sample database. Let me know.

Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
My e*mail address is kavjack@swbell.net. I am getting stuck on this problem. Thanks for your help.
 
I put together a quick DB that does this. Post your email address and I'll send it to you. Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top