Page 1 of 1
Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 11:14 am
by chris_rover
Hi, I am trying to filter data for a dropdown box using the selection criteria as either a field on the screen, or one from in my program. when I try it, no data is displayed. when I substitute the field name with a constant value, the correct data is displayed.
I checked the thread about "Selection criteria ...' but something i must be doing wrong. please help!!!
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 11:33 am
by rmullis
What is the character string in the program field for your selection criteria? I has to be in the same format that you would use in a WHERE clause in SQL. For example, FIELDA = 'ABCDE'.
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 11:41 am
by chris_rover
it is a numeric field. if I use it like this :- code = 3, it works. if I use it like :-
code = in_Code, it doesn't work. "in_code" being defined exactly the same data type as "code".
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 11:50 am
by rmullis
Instead of trying to pull in field in_code into the selection criteria property, define a character field for the selection criteria long enough to hold the complete character string for the selection criteria. Then in your program, load the complete string for the selection crteria into this field you defined for the property.
For example, define a field called SELECT in the selection criteria property that is 20 characters long. In your program, assuming field in_code = 20, you would set field SELECT = 'code = 20'.
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 1:14 pm
by chris_rover
Hi,
that works just the same as if i had coded it in the selection criteria box. however, when I substitute the "20" with the "in_code" variable, I get the same problem of it now selecting any data.
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 1:31 pm
by rmullis
You don't put the name of the field into the character string in your program. You take the value of the field and put that in you character string in your program.
For example, in your program:
Code: Select all
/Free
in_code = 20;
.
.
.
select_string = 'code = ' + %char(in_code);
/End-Free
Then assign field
select_string to the selection criteria property in your drop down box.
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 1:43 pm
by chris_rover
thanks a million. it worked!
Re: Selection criteria for dropdown box, using screen value
Posted: Tue Apr 17, 2012 1:48 pm
by rmullis
Glad I could help.
I am new to ProfoundUI and struggled with a similar situation a couple of weeks ago when trying to dynamically load a subfile grid from a database file with selection criteria. This scenario will work for any widget that is loaded using a database file directly, instead of loading it from the program.