Page 1 of 3

TextEntry Search

PostPosted: Tue Jul 05, 2016 9:02 pm
by Dixan
I´m working in a DB and in a TextEntry I have to write P (planificado) or NP (No Planificado) but when I tried to find all P, appears all P and all NP because P is included in NP, How can I fix it?

Re: TextEntry Search

PostPosted: Tue Jul 05, 2016 10:44 pm
by Gaev
Dixan:

Post your current code here first.

Re: TextEntry Search

PostPosted: Wed Jul 06, 2016 8:10 am
by Dixan
This is What I used:

SetVar "[Filter]" ""

If "[DBCCTi]" ">" ""
SetVar "[Filter]" "Ti = [#34][DBCCTi][#34]"
EndIf

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


It Works perfectly finding names, numbers, and TextEntry with just an X but in this case the patien data is just P or NP and when I try to get all patients with P (Planned) it shows me all patient with P and with NP because the P is included in NP. How can I get just patients with P?

Re: TextEntry Search

PostPosted: Wed Jul 06, 2016 10:02 am
by Gaev
Dixan:

Try ...
Code: Select all
SetVar "[Filter]" "Ti == [#34][DBCCTi][#34]"

... two 'equal signs' means "exact match"

Re: TextEntry Search

PostPosted: Thu Jul 07, 2016 7:29 am
by Dixan
Thanks Gaev. Solved.

Re: TextEntry Search

PostPosted: Fri Jul 08, 2016 8:46 am
by Dixan
Hi again.
I have a TextEntry wich includes the days a patient is in hospital, using:

If "[DBCCEst]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Est = [#34][DBCCEst][#34]"
EndIf

I Can get how many patient stays at hospital for an especific day but, how can I get how many patients was in hospital less than 3 days?

Re: TextEntry Search

PostPosted: Fri Jul 08, 2016 9:01 am
by Gaev
Dixan:

I Can get how many patient stays at hospital for an especific day but, how can I get how many patients was in hospital less than 3 days?

Try ...
Code: Select all
SetVar "[Filter]" "[Filter]Est < [#34][DBCCEst][#34]"


You can also use "comparators" like > (greater than) or <= (less or equal) or >= (greater or equal).

Re: TextEntry Search

PostPosted: Thu Jul 14, 2016 12:10 pm
by Dixan
Hi guys,
I´m trying find in DB intervals but if I don´t write an especific number it write me "No matching records found"
I used this:

IfEx "[DBCCMest] <= 100 AND [DBCCMest] > 90"
If "[Filter]" ">" "90"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 90 AND [DBCCMest] > 80"
If "[Filter]" ">" "80"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 80 AND [DBCCMest] > 70"
If "[Filter]" ">" "70"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 70 AND [DBCCMest] > 60"
If "[Filter]" ">" "60"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 60 AND [DBCCMest] > 50"
If "[Filter]" ">" "50"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 50 AND [DBCCMest] > 40"
If "[Filter]" ">" "40"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 40 AND [DBCCMest] > 30"
If "[Filter]" ">" "30"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 30 AND [DBCCMest] > 20"
If "[Filter]" ">" "20"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 20 AND [DBCCMest] > 10"
If "[Filter]" ">" "10"
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
IfEx "[DBCCMest] <= 10 AND [DBCCMest] > 0"
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf

Re: TextEntry Search

PostPosted: Thu Jul 14, 2016 1:34 pm
by Gaev
Dixan:

1) It is never a good idea to have so many levels of If/Else/EndIf code blocks

2) It is an even worse practice to NOT nest your If/Else/Endif code blocks (use Tabs to make sure it is human readable)

Having said that, and assuming that your code is properly nested (meaning If/Else/EndIf pairs are all OK), why don't you diagnose what the composed [Filter] looks like by adding an AlertBox like this ...
Code: Select all
AlertBox "Filter" "[DBCCMest] ... [Filter]"
... and post the result here.

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 6:47 am
by Dixan
Look, I have 2 datas in this moment, 12 and 95. If I write 10 to find intervals betwen 11 to 20 I get: 10 ..., If I write 10 again I get 10 ... Mest = "10", Always with the las number, if I decide search for 90 after those ones I get: 90 ... Mest = "10" and of course when I close that The no liked "No matching records found"

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 8:14 am
by Gaev
Dixan:
If I write 10 to find intervals betwen 11 to 20 I get: 10 ..., If I write 10 again I get 10 ... Mest = "10", Always with the las number, if I decide search for 90 after those ones I get: 90 ... Mest = "10"

1) Do you enter 10, 90 etc. in a Single Line Text Entry Box ?

2) Is [DBCCMest] the variable associated with this Box ?

3) Is the If/Else/EndIf logic triggered in the Text Change code section of this Box ?

4) Is the AlertBox part of this same code section ?

5) Enter 90 first, then follow up with 10 ... tell us what the AlertBox results were.

Please answer all questions in your reply.

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 8:51 am
by virger
Tray this. Maybe can help you
Prueba esto quiza te ayude.

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=3
Name=PushButton1
X=26
Y=80
W=230
H=35
Anchor=0
Text=[filter]
Align=1
ImageStyle=0
XPTheme=Yes
ObjAction=IfEx "[DBCCMest] <= 100 AND [DBCCMest] > 90"¶    If "[Filter]" ">" "90"¶        SetVar "[Filter]" "[Filter] AND "¶        EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 90 AND [DBCCMest] > 80"¶        If "[Filter]" ">" "80"¶        SetVar "[Filter]" "[Filter] AND "¶        EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 80 AND [DBCCMest] > 70"¶    If "[Filter]" ">" "70"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 70 AND [DBCCMest] > 60"¶    If "[Filter]" ">" "60"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 60 AND [DBCCMest] > 50"¶    If "[Filter]" ">" "50"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 50 AND [DBCCMest] > 40"¶    If "[Filter]" ">" "40"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 40 AND [DBCCMest] > 30"¶    If "[Filter]" ">" "30"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 30 AND [DBCCMest] > 20"¶    If "[Filter]" ">" "20"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 20 AND [DBCCMest] > 10"¶    If "[Filter]" ">" "10"¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶else¶    IfEx "[DBCCMest] <= 10 AND [DBCCMest] > 0"¶    If "[Filter]" ">" ""¶    SetVar "[Filter]" "[Filter] AND "¶    EndIf¶    SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"¶EndIf¶EndIf¶EndIf¶EndIf¶EndIf¶EndIf¶EndIf¶EndIf¶EndIf¶EndIf
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=11
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=9
Name=TextEntry1
X=264
Y=4
W=60
H=35
Anchor=0
Text=85
VarName=[DBCCMest]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16250871
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=9
Name=TextEntry3
X=4
Y=4
W=255
H=35
Anchor=0
Text=91
VarName=[filter]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16250871
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=5
ObjectType=3
Name=PushButton2
X=27
Y=42
W=230
H=35
Anchor=0
Text=[Filter]
Align=1
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[dt1]"    ""¶loop "1" "10" "[c]"¶    math "[dt1]+10" "" "[dt2]"¶    IfEx "[DBCCMest] <= [dt2] AND [DBCCMest] > [dt1]"¶        exitloop¶    endif¶endloop¶If "[Filter]" ">" "[dt1]"¶    SetVar "[Filter]" "[Filter] AND "¶EndIf¶SetVar "[Filter]" "[Filter] Mest = [#34][DBCCMest][#34]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=11
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=6
ObjectType=3
Name=PushButton3
X=10
Y=160
W=76
H=39
Anchor=0
Text=1-9
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=ListBoxDeleteItem "Ls1" "All"¶... genera para simular datos 'DBF'¶.loop "1" "250" "[c]"¶.    Random "100" "[rnd]"¶.    math "[rnd]+1" "" "[num[c]]"¶.    if "[num[c]]" "<" "10"¶.        setvar "[num[c]]" "0[num[c]]"¶.    endif¶.endloop¶¶setvar "[LimInf]" "[Li]"¶¶.. usar [LimInf] filtra¶. 0   1-10¶.10  11-20¶.20  21-30¶.esto si se da esta condicion #1¶.     math "[LimInf]+11" "" "[LimSup]"¶¶¶.se puede alterar¶.. usar [LimInf] filtra¶. 0   1- 9¶.10  10-19¶.20  20-29¶.esto si se da esta condicion #2¶     math "[LimInf]+10" "" "[LimSup]"¶¶math "[LimInf]+1"  "" "[LimInf]"¶loop "1" "250" "[c]"¶    .esto para simular el dato '[DBCCMest]'¶    setvar "[DBCCMest]" "[num[c]]"¶    ifex "[DBCCMest]>=[LimInf] AND [DBCCMest]<[LimSup]"¶        ListBoxAddItem "Ls1" "0" "[DBCCMest]"¶    endif¶endloop¶setvar "[Filter1]" "[#34]DBCCMest[#34]>=[LimInf] AND [#34]DBCCMest[#34]<[LimSup]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14739704
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=8
ObjectType=10
Name=Ls1
X=10
Y=204
W=76
H=269
Anchor=0
VarName=[Num]
VarType=0
Sorted=Yes
XPTheme=Yes
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14739704
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=10
ObjectType=9
Name=TextEntry4
X=109
Y=122
W=60
H=35
Anchor=0
VarName=[Li]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=11598072
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=3
Name=PushButton4
X=94
Y=160
W=76
H=39
Anchor=0
Text=1-10
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=ListBoxDeleteItem "Ls2" "All"¶.. genera para simular datos 'DBF'¶.loop "1" "250" "[c]"¶.    Random "100" "[rnd]"¶.    math "[rnd]+1" "" "[num[c]]"¶.    if "[num[c]]" "<" "10"¶.        setvar "[num[c]]" "0[num[c]]"¶.    endif¶.endloop¶¶setvar "[LimInf]" "[Li]"¶¶.. usar [LimInf] filtra¶. 0   1-10¶.10  11-20¶.20  21-30¶.esto si se da esta condicion #1¶     math "[LimInf]+11" "" "[LimSup]"¶¶¶.se puede alterar¶.. usar [LimInf] filtra¶. 0   1- 9¶.10  10-19¶.20  20-29¶.esto si se da esta condicion #2¶.     math "[LimInf]+10" "" "[LimSup]"¶¶math "[LimInf]+1"  "" "[LimInf]"¶loop "1" "250" "[c]"¶    .esto para simular el dato '[DBCCMest]'¶    setvar "[DBCCMest]" "[num[c]]"¶    ifex "[DBCCMest]>=[LimInf] AND [DBCCMest]<[LimSup]"¶        ListBoxAddItem "Ls2" "0" "[DBCCMest]"¶    endif¶endloop¶setvar "[Filter2]" "[#34]DBCCMest[#34]>=[LimInf] AND [#34]DBCCMest[#34]<[LimSup]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14219488
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=7
ObjectType=10
Name=Ls2
X=94
Y=204
W=76
H=269
Anchor=0
VarName=[Num]
VarType=0
Sorted=Yes
XPTheme=Yes
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14219488
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=9
ObjectType=3
Name=PushButton5
X=9
Y=124
W=77
H=28
Anchor=0
Text=Genere
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=ListBoxDeleteItem "Ls1" "All"¶ListBoxDeleteItem "Ls2" "All"¶.. genera para simular datos 'DBF'¶loop "1" "250" "[c]"¶    Random "100" "[rnd]"¶    math "[rnd]+1" "" "[num[c]]"¶    if "[num[c]]" "<" "10"¶        setvar "[num[c]]" "0[num[c]]"¶    endif¶endloop
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14935011
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=11
ObjectType=8
Name=Text1
X=173
Y=206
W=458
H=44
Anchor=0
Font=Arial
FontSize=11
FontStyle=1
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs22\cf0\b Tipo#1:\par\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs22\cf0\b [filter1]}}}
HMargin=6
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14739704
FillPattern=0
TabOrder=13
ObjectType=8
Name=Text2
X=173
Y=272
W=458
H=44
Anchor=0
Font=Arial
FontSize=11
FontStyle=1
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs22\cf0\b Tipo#2:\par\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs22\cf0\b [filter2]}}}
HMargin=6
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14219488
FillPattern=0
TabOrder=12

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 4:13 pm
by Dixan
Image

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 5:49 pm
by virger
Hola...
El codigo enviado es un grupo de OBJETOS (5), asi que,
1) Abre NB
2) Crea una area de trabajo
3) Copia todo el codigo
4) Pegalo en el area de trabajo y listo

Re: TextEntry Search

PostPosted: Fri Jul 15, 2016 6:18 pm
by Gaev
Dixan:

Thank you for the detailed response.

I edited your code to ...

1) show the indents for the nested If/Else/EndIf code blocks

2) reset the [Filter] variable before going through the logic

3) display via AlertBox, the values of [DBCCMest] and [Filter] both, BEFORE and AFTER the logic block

Code: Select all
SetVar "[Filter]" ""
AlertBox "Before" "[DBCCMest] ... [Filter]"
IfEx "[DBCCMest] <= 100 AND [DBCCMest] > 90"
   If "[Filter]" ">" "90"
      SetVar "[Filter]" "[Filter] AND "
   EndIf
   SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
else
   IfEx "[DBCCMest] <= 90 AND [DBCCMest] > 80"
      If "[Filter]" ">" "80"
         SetVar "[Filter]" "[Filter] AND "
      EndIf
      SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
   else
      IfEx "[DBCCMest] <= 80 AND [DBCCMest] > 70"
         If "[Filter]" ">" "70"
            SetVar "[Filter]" "[Filter] AND "
         EndIf
         SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
      else
         IfEx "[DBCCMest] <= 70 AND [DBCCMest] > 60"
            If "[Filter]" ">" "60"
               SetVar "[Filter]" "[Filter] AND "
            EndIf
            SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
         else
            IfEx "[DBCCMest] <= 60 AND [DBCCMest] > 50"
               If "[Filter]" ">" "50"
                  SetVar "[Filter]" "[Filter] AND "
               EndIf
               SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
            else
               IfEx "[DBCCMest] <= 50 AND [DBCCMest] > 40"
                  If "[Filter]" ">" "40"
                     SetVar "[Filter]" "[Filter] AND "
                  EndIf
                  SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
               else
                  IfEx "[DBCCMest] <= 40 AND [DBCCMest] > 30"
                     If "[Filter]" ">" "30"
                        SetVar "[Filter]" "[Filter] AND "
                     EndIf
                     SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
                  else
                   IfEx "[DBCCMest] <= 30 AND [DBCCMest] > 20"
                        If "[Filter]" ">" "20"
                           SetVar "[Filter]" "[Filter] AND "
                        EndIf
                        SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
                     else
                        IfEx "[DBCCMest] <= 20 AND [DBCCMest] > 10"
                           If "[Filter]" ">" "10"
                              SetVar "[Filter]" "[Filter] AND "
                           EndIf
                        SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
                        else
                           IfEx "[DBCCMest] <= 10 AND [DBCCMest] > 0"
                              If "[Filter]" ">" ""
                                 SetVar "[Filter]" "[Filter] AND "
                              EndIf
                              SetVar "[Filter]" "[Filter]Mest = [#34][DBCCMest][#34]"
                           EndIf
                        EndIf
                     EndIf
                  EndIf
               EndIf
            EndIf
    EndIf
      EndIf
   EndIf
EndIf
AlertBox "After" "[DBCCMest] ... [Filter]"


I ran it ... entering values in the Text Entry Box for 10 and then 90 (as well as 90 and then 10) ... the values shown by the AlertBox commands were as expected.

Please copy this code from the forum and paste it in a Button in your Publication ... tell me if your results are different.