When I choose "LASTNAME" out of the combo box and hit the button, it's giving me a prompt box (parameter box?) with "LASTNAMEDESC" above the empty input box.
Main Topics
Browse All TopicsI have a main form with a datasheet subform that is a reflection of a large table. I would like to sort the fields based on a user's field selection from a combo box. The layout is such: My main form, with the subform in it, a combo box and a button at the bottom of the main form. When the user selects a field name from the combo box and hits the button, the subform will sort accordingly. So far, I've been able to sort it ascending (default), but not descending. Here is my code:
Private Sub Command17_Click()
Me![HPK_Providers subform].Form.OrderByOn = True
Me![HPK_Providers subform].Form.OrderBy = Combo30
End Sub
Easy code, and it works like a charm for sorting ascending, but how can I make this sort descending?
Note: I've tried quotes (i.e. *.orderby = "[Combo30] desc") and brackets and all sorts of things. Also using Access 2K3.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
jet46, that defeats the purpose of the user input. . .our end-user needs to have the ability to choose what field to sort by (I know it sounds confusing, but this db is for a user using Accesss RunTime)
the .orderby = Combo30 works great--it sorts ascending perfectly for each field I choose from the combo box, I just basically want to do the direct opposite.
jet46, Thanks. . .I took your code in your first comment:
****.orderby = "TestTable.DateEntered DESC"****
and modified it a little to look like this:
Me![HPK_Providers subform].Form.OrderBy = "HPK_Providers subform." & Combo30 & " DESC"
to order the subform by the combo box. . .and it works perfectly!
Business Accounts
Answer for Membership
by: perkcPosted on 2005-06-29 at 07:36:13ID: 14328959
Try:
.OrderBy = Combo30 & " DESC"