PDA

View Full Version : Search on Multiple Fields


ABC123

Phil Rolf
12-08-2004, 07:30 PM
I have a grid component with the option "Grid Contains a Search part" selected.

I want to search for data using two fields. How do I set this up?

Thanks

Selwyn Rabins
12-09-2004, 04:25 AM
searching on multiple fields should be completely intuitive, so perhaps I an not understanding your question.

when you define the Search Part you select which fields the user should be able to search on.

say you select firstname, lastname, company, and city in the Search Part.

when you run the page that contains this component, the search part is shown.

if you enter "Phil" in the firstname field and "Rolf" in the lastname field, then the search is for:

firstname = "Phil" .and. lastname = "Rolf"

if you were to also fill in a value in the city field, then the search would be for:

firstname = "Phil" .and. lastname = "Rolf" .and. city = "Boston"

Phil Rolf
12-09-2004, 07:18 AM
That is what I thought, however, if I enter info in one search field (REFNUM) and nothing in the other search field (PIN), it will find the records for the field that I entered search data (REFNUM). Because the 2nd field (PIN)is blank in the search criteria it should not have found any records? Do I have to enter some code to check for data in both search fields? If so, where would I place this check?

Thanks

Selwyn Rabins
12-09-2004, 01:03 PM
if a search field contains nothing in it then it is not part of the search.

if you specifically want to search for for blank values than you can type:

'is blank' or 'is not blank' (without the single quotes) in the field.

Phil Rolf
12-09-2004, 05:17 PM
"if a search field contains nothing in it then it is not part of the search."

Does this still hold true even if I have the option
Combine Search Criteria Using 1
Search Style 1 ?

Selwyn Rabins
12-10-2004, 04:50 AM
yes

Phil Rolf
12-10-2004, 07:44 AM
OK, then let me ask a question relative to checking for blank search fields?

I have looked but have been unable to find where I could place xbasic to check to make sure that you cannot have a blank search field. I know how to do it with the Dialog component. Is there a location to perform this type of check with the "Grid Contains a Search part" option?

Selwyn Rabins
12-10-2004, 09:46 AM
there is not facility in the Grid component to validate the user's search before the search is performed.

if you want to validate the search, you would have to use the Dialog component to collect the search criteria from the user, and then in the dialog component's AfterValidate event, you would have to compute the url necessary to open the page that has your grid in it, passing in the necessary filter expression.

there is an example in the sample web apps where a dialog has 'cascading lookups' and then when the user clicks the submit button, a page containing a grid is opened.

if you study this sample, you should be able to modify it for your needs.

Phil Rolf
12-10-2004, 08:08 PM
I am almost there getting things to work but have come across one problem.

I am transferring DIALOG component information to build a filter for another a5w page. If I have the following line of code in the after validate
filter = "ref_num=" + quote(referee_number) + ".and. pin = " + quote(pin_number)
I get the following error when the redirected page is displayed.
Error 4 - Filter expression has error: ref_num="6799".and. pin = "3646"

ref_num is a numeric field and pin is a character field. How do I change the filter expression to get the filter to work?

Phil Rolf
12-11-2004, 05:21 AM
I found a couple errors of my ways and got it to work...

Michael Vytilingam
08-30-2005, 07:16 PM
Sorry I have the same problem as Rolf, can somebody tell me the correct syntax.
Thanks

Michael Vytilingam
08-30-2005, 10:06 PM
Solved.
Basically be careful of numeric and character fields and how you set expressions for them.