Page 2 of 3

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 8:27 pm
by Dixan
well Gaev, I did wat you told me, result Before 10 ... After 10 ... Mest = "10"

Let me try to explain myselfe better, I would like if I write example 10, get all patients from 1 to 10, I mean all patients who have an estimated mortality from 1 to 10, if I write 20 get all patients who have an estimatd mortality less than 20, if I write 30 all patien less than 30 and so on. I can get the specific number without problem, if I write 10 I get all patien with Mest 10 and if I write 90 I get all patients with Mest 90, but I want to get an interval less than the number I write until 0. I don´t know if I explain it correctly.

Re: TextEntry Search

PostPosted: Sat Jul 16, 2016 5:06 am
by Gaev
Dixan:

well Gaev, I did wat you told me, result Before 10 ... After 10 ... Mest = "10"

So, what exactly was causing you to get unexpected results that you posted before ?

Let me try to explain myselfe better, I would like if I write example 10, get all patients from 1 to 10, I mean all patients who have an estimated mortality from 1 to 10, if I write 20 get all patients who have an estimatd mortality less than 20, if I write 30 all patien less than 30 and so on. I can get the specific number without problem, if I write 10 I get all patien with Mest 10 and if I write 90 I get all patients with Mest 90, but I want to get an interval less than the number I write until 0. I don´t know if I explain it correctly.

I think i understand the requirement.

So far, you have been composing a [Filter] like ...

Mest = [#34][DBCCMest][#34]

... where [DBCCMest] is entered as 90 or 80 or 70 etc. ... what you are looking for is a [Filter] like ...

Mest <= [#34][DBCCMestUpper][#34] AND Mest > [#34][DBCCMestLower][#34]

... you can ...

a) either have two TextEntry Boxes with associated variables [DBCCMestUpper] and [DBCCMestLower]

b) or calculate the lower range based on the upper range entered in [DBCCMest]


Note: For dbfQuery to process <= and > conditions properly, your database field Mest has to be defined as a numeric field (not a string).

Re: TextEntry Search

PostPosted: Sat Jul 16, 2016 12:30 pm
by Dixan
Well, I don´t know if it´s correct, in this way I used following your examples:

SetVar "[Filter]" "[Filter]Mest <= [#34][DBCCMest][#34]"

But as I´ll be working with decimal (12.25) I changed string by Currency and it works fine, I got my spected answer,

Now, I have many TextEntry boxes but the cursor appears in the TextEntry box I have with currency.
How I get it appears in the first TextEntry box?

Re: TextEntry Search

PostPosted: Sat Jul 16, 2016 12:39 pm
by Gaev
Dixan:

Now, I have many TextEntry boxes but the cursor appears in the TextEntry box I have with currency.
How I get it appears in the first TextEntry box?

You can set the "Tab Order" of objects on a page (from Arrange menu, select Set Tab Order).

Also, take a look at FocusObject command if you ever want to change the order at run time.

Re: TextEntry Search

PostPosted: Sat Jul 16, 2016 3:15 pm
by Dixan
:lol: Got it :lol: Thanks a lot guys :lol:

Re: TextEntry Search

PostPosted: Sat Aug 13, 2016 10:10 pm
by Dixan
Hello Again,
Traying to not use so much comands in serching button I used this (Thanks Virger):

strparse "NOMBRE.APELLIDOS.EDAD.SEXO.RAZA.HC.PROCED.TI.APACHE.MEST.DI.FID.FIM.FIA.DE.FED.FEM.FEA.PAMI.EST.SEP" "." "[campo]" "[nc]"
SETVAR "[BSAND]" "AND"
SETVAR "[BSOR]" "OR "
setvar "[filter]" ""
loop "1" "[nc]" "[c]"
if "[DBCC[campo[c]]]" "<>" ""
setvar "[filter]" "[filter] [campo[c]]=[#34][DBCC[campo[c]]][#34] [BSAND]"
endif
endloop
strlen "[filter]" "[len]"
substr "[filter]" "1" "[len]-4" "[filter]"

But there are 3 textentry box I need to find all "<=" to an specific number, how to do that ?

Re: TextEntry Search

PostPosted: Sun Aug 14, 2016 6:23 am
by Gaev
Dixan:

But there are 3 textentry box I need to find all "<=" to an specific number, how to do that ?

Sorry, I don't understand what you are asking (something is being lost in translation) ... so provide a clear example e.g. ...

a) TextEntry Box variables are [TextEntry1], [TextEntry2] and [TextEntry3]

b) I want to find all records where "blah blah blah" <= "more blah"

Re: TextEntry Search

PostPosted: Sun Aug 14, 2016 5:52 pm
by Dixan
Ok, step by step...

I have a pub with many TextEntry boxes, like: NOMBRE, APELLIDOS, EDAD, SEXO, RAZA, HC, PROCED, TI, APACHE, MEST, DI, FID, FIM, FIA, EST, and others.
My DB is DBCC.dbf
In the search button I was using these:

SetVar "[Filter]" ""

If "[DBCC.Nombre]" ">" ""
SetVar "[Filter]" "Nombre = [#34][DBCC.Nombre][#34]"
EndIf

If "[DBCC.Apellidos]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Apellidos = [#34][DBCC.Apellidos][#34]"
EndIf

If "[DBCC.Est]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Est <= [#34][DBCC.Est][#34]"
EndIf

...

If "[Filter]" ">" ""
dbfQuery "DBCC.dbf" "[Filter]"
Else
dbfShowAll "DBCC.dbf"
EndIf

CloseCustomWindow "QueryDialog"


But I had to have an "if/endif" for each var.

So Virger suggest me to use:

strparse "NOMBRE.APELLIDOS.EDAD.SEXO.RAZA.HC.PROCED.TI.APACHE.MEST.DI.FID.FIM.FIA.DE.FED.FEM.FEA.PAMI.EST.SEP" "." "[campo]" "[nc]"
SETVAR "[BSAND]" "AND"
SETVAR "[BSOR]" "OR "
setvar "[filter]" ""
loop "1" "[nc]" "[c]"
if "[DBCC[campo[c]]]" "<>" ""
setvar "[filter]" "[filter] [campo[c]]=[#34][DBCC[campo[c]]][#34] [BSAND]"
endif
endloop
strlen "[filter]" "[len]"
substr "[filter]" "1" "[len]-4" "[filter]"


It was useful for search all vars, so much easy than a large one I was using, but I had 3 TextEntry boxes were I was using:
SetVar "[Filter]" "[Filter]Est <= [#34][DBCC.Est][#34]"

My Question now is how to get a search with this new form, that help me to get all "<=" just in that 3 TextEntry boxes?

Re: TextEntry Search

PostPosted: Sun Aug 14, 2016 8:53 pm
by Gaev
Dixan:

Assuming the three variables that require a comparison of "<=" instead of "=" are APELLIDOS, EDAD and EST ...
Code: Select all
strparse "NOMBRE.APELLIDOS.EDAD.SEXO.RAZA.HC.PROCED.TI.APACHE.MEST.DI.FID.FIM.FIA.DE.FED.FEM.FEA.PAMI.EST.SEP" "." "[campo]" "[nc]"
strparse "!=.<=.<=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.<=.=" "." "[campotype]" "[nct]"

SETVAR "[BSAND]" "AND"
SETVAR "[BSOR]" "OR "

setvar "[filter]" ""
loop "1" "[nc]" "[c]"
   if "[DBCC[campo[c]]]" "<>" ""
      setvar "[filter]" "[filter] [campo[c]][campotype[c][#34][DBCC[campo[c]]][#34] [BSAND]"
   endif
endloop

strlen "[filter]" "[len]"
substr "[filter]" "1" "[len]-4" "[filter]"

Re: TextEntry Search

PostPosted: Mon Aug 15, 2016 8:52 am
by Dixan
Thanks Gaev this works almost perfect, just a little problem with the Var "Age" because it is not a TextEntry var it´s a Combo Box, I wrote "<=" for it but it shows me all Ages . Suggest?

Re: TextEntry Search

PostPosted: Mon Aug 15, 2016 10:56 am
by Gaev
Dixan:

it is not a TextEntry var it´s a Combo Box, I wrote "<=" for it but it shows me all Ages . Suggest?

When you ask to query a "text" (non-numeric) value using "<=" (or ">="), the comparison is different e.g. ...

- JOHN is considered less than JOHNSON
- 2 is considered more than 17 or 194

... if you have single and double digit values, you will have to add zeroes in front of single digit ... you can do this in the Selection Changed event section ... and use the variable containing the modified value to do your filter/query.

Otherwise, tell us what possible values this ComboBox variable can take.

Re: TextEntry Search

PostPosted: Mon Aug 15, 2016 11:12 am
by Dixan
In Age I have from 17 to 106 I used "<=" and search for 40 and shows me all ages I have in DB even 46 that is the higest I have in this moment

Re: TextEntry Search

PostPosted: Mon Aug 15, 2016 12:19 pm
by Gaev
Dixan:

In Age I have from 17 to 106 I used "<=" and search for 40 and shows me all ages I have in DB even 46 that is the higest I have in this moment

As mentioned in my previous post, when querying text fields, 17 and 106 are both considered less than 40 (the comparison is done one character at a time, from left to right).

But I am not sure why it returned the record with value 46 ... how is your DB field defined ? ... numeric or text ?

Temporarily, set up a Push Button to try out many filter scenarios (just for this one field) e.g. ...

- less than 17
- greater than 106
- values in between

... post here, the values of the filter and the records returned (i.e. value of Age field in the records).

Re: TextEntry Search

PostPosted: Mon Aug 15, 2016 12:38 pm
by Dixan
Was a mistake, I had the Age var in string, I changed to Integer and problem solved, thanks.

Re: TextEntry Search

PostPosted: Wed Aug 17, 2016 2:29 pm
by Dixan
Ok Guys, an unespected change

I was using this perfectly:
Strparse "NOMBRE.APELLIDOS.EDAD.SEXO.RAZA.HC.PROCED.TI.APACHE" "." "[campo]" "[nc]"
strparse "!=.=.<=.=.=.=.=.=.<=" "." "[campotype]" "[nct]"

SETVAR "[BSAND]" "AND"
SETVAR "[BSOR]" "OR "

setvar "[filter]" ""
loop "1" "[nc]" "[c]"
if "[DBCC[campo[c]]]" "<>" ""
setvar "[filter]" "[filter] [campo[c]][campotype[c][#34][DBCC[campo[c]]][#34] [BSAND]"
endif
endloop

strlen "[filter]" "[len]"
substr "[filter]" "1" "[len]-4" "[filter]"

But Now I have to change Age var from TextEnry box to a combobox with a group of ages "17-30/31-45/46-60/61-75/>75" and Apache for a combobox "<25/>25" I was using "<=" as you can see above but now it doesn´t work, it´s different, how can I do that?