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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two Filter/Sort questions

Status
Not open for further replies.

JohnVDB

Programmer
Nov 26, 2002
8
US
I have two questions regarding filtering and sorting.

1) On some of my forms, I do not seem to be allowed to filter the data. This is particularly annoying for one table that has over 3500 records in it. I have some forms that allow filtering when I bring them up in a stand alone mode but when they are opened by another form they won't allow it. Any ideas or ways to guarantee filtering to be turned on?

2) When I want to remove a filter, it also removes the sort. For example, I have a list of people that I have sorted by last name. I might want to filter it to just those whose name begins with "P". After I'm done, I want to go back to the complete list. Right now I have to remove the filter/sort and the re-sort or else the names come out in some odd order. Is there a way to prevent this? Is there an event that is triggered that I could override and do a sort so the user doesn't have to?
 
Point 2:

Instead of removing the filter, apply another filter which only sets the sort, but shows all records. ie Sort Ascending, no criteria.
 
SeeThru,

That sorts the filtered set. It doesn't bring back the entire set in a sorted order.
 
Are you applying the filter in code?

If you are, you can hard code the fiter to apply:

Forms!contacts.Filter = "Contacts.LastName FROM Contacts ORDER BY Contacts.LastName"
Forms!contacts.FilterOn = True
Forms!contacts.Requery

This replaces any current filter with one that sorts by LastName - whatever was previously set is irrelevant.

Also, I tend to use variables for the filter string, so you can have lots of preset filters availalbe to users. Store the filter strings in a table, and users can make and save thier own for later use.
 
At this point, I'm not coding the filter. This is when the user right clicks in a field and chooses to filter the data. I'll provide some pre-canned filters in code that might save them the trouble which would be nice. Since my users aren't too sophisticated I probably won't give the the ability to write their own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top