Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set filter to search?

Status
Not open for further replies.

august

MIS
Aug 24, 2000
150
PH
How can i search records using filters? combining a option group and a textbox. If a have a form then there is an option group to select for a field then i have a text box use to input the text to search. how can i make this happend please help me!

august
[sig][/sig]
 
august

* Add a new form property called .DataToFind
* Add a new grid, grdTABLE, .RecordSource being TABLE you want to search
* Place this code in the KeyPress event of the textbox
* You will need to decide what filter expression is appropriate, determined by your OptionGroup.
* As you type in your string, the number of records shown in .grdTABLE will reduce until you can see the one you want.

IF LASTKEY() = 3 OR ;
[tab][tab]LASTKEY() = 5 OR ;
[tab][tab]LASTKEY() = 9 OR ;
[tab][tab]LASTKEY() = 15 OR ;
[tab][tab]LASTKEY() = 24 OR ;
[tab][tab]LASTKEY() = 27
[tab]MESSAGEBOX([You have pressed the wrong key] ,;
[tab][tab]0 + 48 + 0 ,;
[tab][tab][Invalid keypress])
ELSE
[tab]SELE TABLE
[tab]THISFORM.DataToFind = ALLT(THIS.Value)+ CHR(nkeyCode)
[tab]SET FILTER TO ;
[tab][tab]UPPER(THISFORM.DataToFind) $ UPPER(TABLE.field_1) OR ;
[tab][tab]UPPER(THISFORM.DataToFind) $ UPPER(TABLE.field_2) OR ;
[tab][tab]UPPER(THISFORM.DataToFind) $ UPPER(TABLE.field_3) OR ;
[tab][tab]UPPER(THISFORM.DataToFind) $ UPPER(TABLE.field_4) OR ;
[tab][tab]UPPER(THISFORM.DataToFind) $ UPPER(TABLE.field_5)
[tab]THISFORM.grdTABLE.Refresh()
ENDIF

* To clear the filter - SET FILTER TO

Chris [sig][/sig]
 
It may clarify things if you state what you are putting in your option group for filtering. Is it like:

Search on:
------------------
| |
------------------
Search Type:
O ALL O DATE O FILTER3 O FILTER4

If so, simply catch the option chosen and use a CASE statement. I suppose you are using a Command Button to start the search.

* cmdSearch.Click()
DO CASE
CASE Thisform.opgSearchType = 1
* set filter

etc.

ENDCASE

HTH [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>ICQ #9466492<br>
ICQ VFP ActiveList #73897253[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top