Connecting Tech Pros Worldwide Help | Site Map

How To Re-Filter Data

  #1  
Old June 29th, 2009, 10:41 AM
Member
 
Join Date: Nov 2008
Posts: 40
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 ?
  #2  
Old June 29th, 2009, 12:08 PM
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 344
Provided Answers: 5

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
  #3  
Old June 29th, 2009, 12:58 PM
Member
 
Join Date: Nov 2008
Posts: 40

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
  #4  
Old June 29th, 2009, 03:47 PM
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 344
Provided Answers: 5

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
  #5  
Old June 29th, 2009, 04:04 PM
Member
 
Join Date: Nov 2008
Posts: 40

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.
  #6  
Old June 30th, 2009, 08:08 AM
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 344
Provided Answers: 5

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
  #7  
Old July 1st, 2009, 06:45 AM
Member
 
Join Date: Nov 2008
Posts: 40

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, 6 views)
  #8  
Old July 1st, 2009, 12:11 PM
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 344
Provided Answers: 5

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
  #9  
Old July 1st, 2009, 02:14 PM
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 610
Provided Answers: 2

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,
  #10  
Old July 1st, 2009, 06:20 PM
Member
 
Join Date: Nov 2008
Posts: 40

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.
  #11  
Old July 1st, 2009, 07:17 PM
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 610
Provided Answers: 2

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.
  #12  
Old July 2nd, 2009, 07:04 PM
Member
 
Join Date: Nov 2008
Posts: 40

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.
  #13  
Old July 2nd, 2009, 08:31 PM
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 610
Provided Answers: 2

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.
  #14  
Old July 3rd, 2009, 08:04 AM
Member
 
Join Date: Nov 2008
Posts: 40

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Shifting Between Records Neil answers 4 March 24th, 2008 12:05 AM
Saving to data base aaa answers 3 August 25th, 2006 02:45 PM
Data structure for dynamic two-dimensional array PontiMax answers 1 November 18th, 2005 02:33 PM
Data Access Problem when importing custom file Alex answers 5 November 17th, 2005 08:35 PM
Data disappear - SQL server 2000 / ASP interface HB Kim answers 10 July 20th, 2005 06:17 AM