473,419 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Why do my continuous form filter boxes stop working when I change the record source?

137 100+
Situation:
I'm using a continuous form to display a lot of information stored in a datasheet. I'm using the form because it allows me to display multiple rows of information per 'record' which is needed as some of the records have a lot of text.

However, I've needed to apply both a form of filtering system, and a way of re-ordering the form so that it is alphabetical/numerical order, depending on whiching heading is clicked. I have achieved both of these. Firstly for the filters, I used the code suggested in the dedicated thread by NeoPa on this site, which I've copied in below. For the re-ordering, I've used what you could describe as a bit of a trick, as I couldn't find an easier way - I've created a separate query for each heading, where each query re-orders a specific row. Upon clicking the headers on the form, this changes the form's recordsource between these different queries, thus changing the order.

Problem:
Both the filters and the re-order queries work perfectly well on their own, however combining both the two seems to produce some a strange problem:

If I input a value into a filter box, it filters the box. If I then click a heading, it changes the recordsource, however doesn't re-filter the new information. If I then go into the filter box and hit enter for it to re-filter, it does nothing.

This is the coding for the filter process:

Expand|Select|Wrap|Line Numbers
  1. Private Sub RunFilter()
  2. Dim strFilter As String, strOldFilter As String
  3.  
  4. 'CheckFilter produces the new Filter depending on the values currently in
  5. 'the various filter boxes.
  6.  
  7.     strOldFilter = Me.Filter
  8.     'FilterRef_ID - Numeric
  9.     If Me!FilterRef_ID > "" Then _
  10.         strFilter = strFilter & _
  11.                     " AND ([Ref_ID]=" & _
  12.                     Me!FilterRef_ID & ")"
  13.     'FilterPageTitle - Text
  14.     If Me!FilterPageTitle > "" Then _
  15.         strFilter = strFilter & _
  16.                     " AND ([PageTitle] Like '*" & _
  17.                     Me!FilterPageTitle & "*')"
  18.     'FilterPageAddress - Text
  19.     If Me!FilterPageAddress > "" Then _
  20.         strFilter = strFilter & _
  21.                     " AND ([PageAddress] Like '*" & _
  22.                     Me!FilterPageAddress & "*')"
  23.     'FilterFieldElement - Text
  24.     If Me!FilterFieldElement > "" Then _
  25.         strFilter = strFilter & _
  26.                     " AND ([Field/Element] Like '*" & _
  27.                     Me!FilterFieldElement & "*')"
  28.     'FilterTestFor - Text
  29.     If Me!FilterTestFor > "" Then _
  30.         strFilter = strFilter & _
  31.                     " AND ([TestFor] Like '*" & _
  32.                     Me!FilterTestFor & "*')"
  33.     'FilterType - Text
  34.     If Me!FilterType > "" Then _
  35.         strFilter = strFilter & _
  36.                     " AND ([TypeOfTest] Like '" & _
  37.                     Me!FilterType & "*')"
  38.     'FilterPriority - Text
  39.     If Me!FilterPriority > "" Then _
  40.         strFilter = strFilter & _
  41.                     " AND ([Priority] Like '" & _
  42.                     Me!FilterPriority & "*')"
  43.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  44.     If strFilter <> strOldFilter Then
  45.         Me.Filter = strFilter
  46.         Me.FilterOn = (strFilter > "")
  47.     End If
  48. End Sub
  49.  
  50.  
Each filter box calls this process in it's AfterUpdate event.

At first I thought that this is what was causing the problem, as changing the record source does not 'update' the filter boxes. However I have tried changing the event to things like On Current, calling the RunFilter process on the Form's AfterUpdate/OnCurrent events - I've even tried assigning the value of the filter to a variable, changing the value of the filter to a hardcoded value and then changing it back to the filter value stored in the variable. Still none of these solve the problem.

So I put my query to this community, in the hope that someone can solve my problem with what will probably be a very obvious answer.

Thanks in advance.
Jan 27 '11 #1

✓ answered by TheSmileyCoder

Im not 100% sure about this, but try moving the Me.FilterOn outside of the if-statement.
Expand|Select|Wrap|Line Numbers
  1.     If strFilter <> strOldFilter Then 
  2.         Me.Filter = strFilter 
  3.         Me.FilterOn = (strFilter > "") 
  4.     End If 

4 2259
TheSmileyCoder
2,322 Expert Mod 2GB
Well if you simply enter the textbox and click enter without changing anything the AfterUpdate will not run (since it was not updated).

I would suggest to simply add the RunFilter at the bottom of whatever procedure you have linked to clicking a heading.
Jan 27 '11 #2
Adam Tippelt
137 100+
Tried that. Didn't work.

It still required me to change the text in the filter box first, and then it would filter.
Jan 27 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
Im not 100% sure about this, but try moving the Me.FilterOn outside of the if-statement.
Expand|Select|Wrap|Line Numbers
  1.     If strFilter <> strOldFilter Then 
  2.         Me.Filter = strFilter 
  3.         Me.FilterOn = (strFilter > "") 
  4.     End If 
Jan 27 '11 #4
Adam Tippelt
137 100+
Bingo. I knew it would be an easy fix that I'd overlooked.

Thanks Smiley.
Jan 27 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sham | last post by:
I have a form that is used for entering data. The problem is I have several tables, so I need some way to change the form's record source via combo box. 1. How can I make the combo box look for...
3
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
14
by: Mark | last post by:
How can the instances of a textbox control on an continuous form be addressd? Can a specific instance be addressed? For example, a continuous form has ten records. How can the textbox for the...
4
by: steph | last post by:
Hi, A question regarding Access 2002: I've got a form which should be displayed in Form View and in Datasheet View. But I want to use a different record source for each view. That means, when...
2
by: Shawn Yates | last post by:
I have a form with two subforms on it which are both continous forms. The subform on the left shows the tasks that the employee was assigned to accomplish (each as a seperate record) while the one...
3
by: ApexData | last post by:
I am using a continuous form for display purposes. Above this form, a single record is displayed so that when the user presses my NewButton they can enter a NewRecord which gets added to the...
3
by: lds | last post by:
On our server we have both applications that have been migrated to use v2.0 of the framework as well as apps that have not yet been migrated and still use 1.1. When I tried to deploy my v2.0 app...
2
by: troy_lee | last post by:
I have a subform being displayed as a continuous form. One of the fields for each record is a combo box with two options- removal or installation. How do I color all the fields for the row based...
15
beacon
by: beacon | last post by:
Hi everybody, Using Access 2003. I'm trying to dynamically set the record source for the current form and set the control source for a text box to input data to one of three tables. I have a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.