Connecting Tech Pros Worldwide Forums | Help | Site Map

How To Re-Filter Data

Member
 
Join Date: Nov 2008
Posts: 40
#1: Jun 29 '09
Hi everyone,

I have a form for departments and personnel. There are there fields for the sake of search:

DepartmentSearch as combo box
Division\UnitSearch as combo box
Number as combo box

the user should selcet values form those and press the button( I 'm usnig Macro) to filter data. So far, everything works fine but when re-select other values to look for other data it doesnt work!! it keeps giving me the same result

How to solve this problem ?

Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#2: Jun 29 '09

re: How To Re-Filter Data


Quote:

Originally Posted by ahd2008 View Post

Hi everyone,

I have a form for departments and personnel. There are there fields for the sake of search:

DepartmentSearch as combo box
Division\UnitSearch as combo box
Number as combo box

the user should selcet values form those and press the button( I 'm usnig Macro) to filter data. So far, everything works fine but when re-select other values to look for other data it doesnt work!! it keeps giving me the same result

How to solve this problem ?

Hi
You have not indicated how you are applying the filter in the first instance, but if the form filtering controls are linked to the Record Source of the form (ie. a Stored Query), them I suggest you insert Me.Requery in the After Update event for the filtering controls.

MTB
Member
 
Join Date: Nov 2008
Posts: 40
#3: Jun 29 '09

re: How To Re-Filter Data


I'm full of gratitude to you Sir and sorry i didnt provide sufficient details.

the way i do the filter proceess is by using Macro. As i mentioned the user should select the Department and the Division or Unit and its number then click button which run the Macro. Everything goes as planned but when I want to select other department it doesnt work. !! it gives me the same result for the previous search.

Also when i click the Toggle Filter button on the upper side of the window to trun off filter and try again i get the same result. Moreover, I tried Me.Requery but it doesnt work too.

in regard to your question, the filtering controls are not inked to the recourd source

Looking forward to your assistance
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#4: Jun 29 '09

re: How To Re-Filter Data


Quote:

Originally Posted by ahd2008 View Post

I'm full of gratitude to you Sir and sorry i didnt provide sufficient details.

the way i do the filter proceess is by using Macro. As i mentioned the user should select the Department and the Division or Unit and its number then click button which run the Macro. Everything goes as planned but when I want to select other department it doesnt work. !! it gives me the same result for the previous search.

Also when i click the Toggle Filter button on the upper side of the window to trun off filter and try again i get the same result. Moreover, I tried Me.Requery but it doesnt work too.

in regard to your question, the filtering controls are not inked to the recourd source

Looking forward to your assistance

Hi again

I thing it would be usefull if you posted the macro code, we might then be able to be more specific in our reply.

MTB
Member
 
Join Date: Nov 2008
Posts: 40
#5: Jun 29 '09

re: How To Re-Filter Data


Here you go

I put this code into where condition part of the macro

Expand|Select|Wrap|Line Numbers
  1. [Departments.Department Name] Like [Forms]![Departments and Personnel]![DepartmentSearch] And [Units&Divisions.UDName] Like [Forms]![Departments and Personnel]![UnitDivisionsearch] and [Units&Divisions.Number]=[Forms]![Departments and Personnel]![NumberSearch] 
appreciate your help.
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#6: Jun 30 '09

re: How To Re-Filter Data


Quote:

Originally Posted by ahd2008 View Post

Here you go

I put this code into where condition part of the macro

Expand|Select|Wrap|Line Numbers
  1. [Departments.Department Name] Like [Forms]![Departments and Personnel]![DepartmentSearch] And [Units&Divisions.UDName] Like [Forms]![Departments and Personnel]![UnitDivisionsearch] and [Units&Divisions.Number]=[Forms]![Departments and Personnel]![NumberSearch] 
appreciate your help.

Unfortunately the line of code posted does not give any clue as to how you are filtered the form originally or how you are trying to re-filter it after changing the filter criteria.

It would be better if you posted the complete Macro/Sub !?


MTB
Member
 
Join Date: Nov 2008
Posts: 40
#7: Jul 1 '09

re: How To Re-Filter Data


Thanks for your support.

I attached my database now. The way i filter the form i click on the search button to show the hidden fields (Department and Unit\Division) on the form. After that, i fill out the fields and click the search button which includes macro to do filter.

Thanks again
Attached Files
File Type: zip PTDT.zip (725.7 KB, 7 views)
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#8: Jul 1 '09

re: How To Re-Filter Data


Quote:

Originally Posted by ahd2008 View Post

Thanks for your support.

I attached my database now. The way i filter the form i click on the search button to show the hidden fields (Department and Unit\Division) on the form. After that, i fill out the fields and click the search button which includes macro to do filter.

Thanks again

Hi

Unfortunatly our IT policy will not permit down loading (or opening) files from the internet (as you can imagine this is a great source of frustation!). Therefore, I cannot be of any help unless you post the actual code.

MTB
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 618
#9: Jul 1 '09

re: How To Re-Filter Data


This is why I don't like to use macro's. But if you insist then in your search macro just add a REQUERY action after your APPLYFilter line.

For the REQUERY action you do not put in any parameters for the control. (No parameter means to requery the underlying form).

cheers,
Member
 
Join Date: Nov 2008
Posts: 40
#10: Jul 1 '09

re: How To Re-Filter Data


Sorry to pester you the whole code is already posted besides I explained the way i use the macro.

I dont know what the problem is and thanks for you help all. it seems i cant clearly deliver my concern.

Anyhow, if we could start over and provide me with other method to do search on form by using unbound fields i would appreicate it.
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 618
#11: Jul 1 '09

re: How To Re-Filter Data


Maybe you misunderstood me.

Using the code you have all you need to do is REQUERY the form. So in your search macro you add a line at the end to do a REQUERY.

Go into design mode and after your last line you add a requery. In the action column add the command REQUERY. That's it.

cheers,

Quote:

Originally Posted by ahd2008 View Post

Sorry to pester you the whole code is already posted besides I explained the way i use the macro.

I dont know what the problem is and thanks for you help all. it seems i cant clearly deliver my concern.

Anyhow, if we could start over and provide me with other method to do search on form by using unbound fields i would appreicate it.

Member
 
Join Date: Nov 2008
Posts: 40
#12: Jul 2 '09

re: How To Re-Filter Data


thanks all for your support and the fruitful suggestions.

it works now i put the code Requery after macro code.

Althoug i know what is the major function of Requery but i'm still curious to know how it programatically makes it work.

I will be more than grateful if you explian this aspect

Thanks again.
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 618
#13: Jul 2 '09

re: How To Re-Filter Data


The Requery method does one of the following:

1. Reruns the query on which the form or control is based.
2. Displays any new or changed records or removes deleted records from the table on which the form or control is based.
3. Updates records displayed based on any changes to the Filter property of the form.

The 3rd one applies to your scenario. You were changing the filter property of the form. This won't update your data until you do a requery.

The problem with using the built in Wizard to create your macro's is that the M$ designers cannot take into account every scenario that you may want to implement. You still may need to tweak the macro generated by the wizard. Unfortunately most beginners assume the Wizard is foolproof and can read their minds on what exactly they want done. I think if you really want to learn Access and continue using it for future projects that you learn how to program with it and leave the macro's behind.

Anyways good luck with your project.

cheers,


Quote:

Originally Posted by ahd2008 View Post

thanks all for your support and the fruitful suggestions.

it works now i put the code Requery after macro code.

Althoug i know what is the major function of Requery but i'm still curious to know how it programatically makes it work.

I will be more than grateful if you explian this aspect

Thanks again.

Member
 
Join Date: Nov 2008
Posts: 40
#14: Jul 3 '09

re: How To Re-Filter Data


thanks you a lot. what i was aware of is number 3

Yes i do want to use it for futuer and I'll be more than glad if you enlighten me in how to use better alternative than marco.

Thanks again ,which you marvelous luck.
Reply