Nov 13 2006, 06:05 PM
I have 2 quries one makes a new a table using info from my main table and the other 1 add more info. How can I write code that will just filter the main table using the same logic.
1st query says give all the items where excld critera is "NE" and bill status critera <> BU. this makes the table.
then 2nd query says gve me all itmes where the excld <>"NE and the bill status = "BU".
I have a main and a sub form and when they click a command button I wanted to have code that will filter the main table and only provide me with the logic I have above. and when I click the all command button remove this filter and just show me everything.
Nov 13 2006, 07:04 PM
It seems to me that very little coding is needed. You could create a Filter By Form using the two sets of criteria in the "Look for" and "Or" tabs. Then the button would toggle the FilterOn property:
Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click
If Me.FilterOn Then
Me.cmdFilter.Caption = "Filter On"
Me.FilterOn = False
Me.cmdFilter.Caption = "Filter Off"
Me.FilterOn = True
Nov 13 2006, 07:25 PM
will this work with the other filters I all ready have.
They have three options show me All,Past Dues, Current.
All would just clear all filters and show me everything.
Past dues should filter the form and only show me items that fit the criteria I posted earlier and
Current should filter the form and show me another criteria that I have to set.
Nov 13 2006, 07:40 PM
I recently created a little demo to allow you to create a filter using Filter by Form and saving the filter then recalling it whenever you need it. Nothing fancy, but maybe it will work for you.
Nov 13 2006, 07:58 PM
here is a copy of what I am working on. the past due button makes the main table visible and shows me all the records.
Currently I am take two quries to make another table and I was going to make another subform and then add it to the mainform. Then when they click on current command button and that form would become visible with scrubbed info.
But what I really want is to be able to just click current and have code that just filters the main table to show me the logic that I now have in the two step query.
Nov 13 2006, 08:12 PM
This db looks very familiar. I think I commented before, in another thread, to take a look at this article
. Using this method you can filter on no combo boxes or all of them or in any combination and it will work. I think you are making this harder than necessary as you do not need to create a table, etc. Spend a little time using the code in the article and I think it will pay big rewards...
Nov 13 2006, 08:23 PM
but this confuses me. I have never had to add this many filters.
Nov 13 2006, 08:56 PM
I realize that that code in the article looks intimidating, but if you dive in and work with if for a bit it will all start to make sense. It will stand you in good stead when you have even more complex queries to create so I suggest you invest the time now as it will save you time later and will make your db much more flexible than it is now.... Nothing ventured, nothing gained....
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here