Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / February 2008

Tip: Looking for answers? Try searching our database.

Using Where clause in Macro (ApplyFilter) for Search Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hikaru - 12 Feb 2008 05:42 GMT
I am using a macro (ApplyFilter) on a button to search in the database for
records the match the search details entered.

I wrote in:
Filter Name: select * from Out
Where Condition: ([Out]![year]=[Forms]![Out_Search_3]![combo_year] And
[Out]![Out_num]=[Forms]![Out_Search_3]![txt_Out_num]) Or
([Out]![year]=[Forms]![Out_Search_3]![combo_year] Or
[Out]![Out_num]=[Forms]![Out_Search_3]![txt_Out_num])

I have a search combobox (combo_year) with yeas from (2001-2015) and a
search text (txt_Out_num) for the user to enter any number (ID) to search for
its record.

what I want is to get the search result as following:
to match both fields together if both entered
or
to match only the the entered field if one field only entered

also the in the search text of the Number (ID), it should get all IDs the
has number 2 in them if number 2 was entered in the search field for example.
to explain, if the database has IDs like (2, 255 and 5) it should show in the
results of both records of (2 and 255) because both have number 2 in them.

i hope you understand my problem.
any help is appreciated, thanks.
Ken Snell (MVP) - 23 Feb 2008 15:48 GMT
Try this for the Where argument:

([Out]![year]=[Forms]![Out_Search_3]![combo_year] And
[Out]![Out_num]=[Forms]![Out_Search_3]![txt_Out_num]) Or
([Out]![year]=[Forms]![Out_Search_3]![combo_year] Or
([Out]![Out_num]Like [Forms]![Out_Search_3]![txt_Out_num] & "*"
And [Forms]![Out_Search_3]![txt_Out_num] Is Not Null))

Signature

       Ken Snell
<MS ACCESS MVP>

>I am using a macro (ApplyFilter) on a button to search in the database for
> records the match the search details entered.
[quoted text clipped - 25 lines]
> i hope you understand my problem.
> any help is appreciated, thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.