Selecting SETRANGE

elToritoelTorito Member Posts: 191
Hmm.

Problem: I Would Set a Filter ...
I Have 3 Boolean Fields, ...

Field1 can be TRUE or FALSE
Field2 can be TRUE or FALSE
Field3 can be TRUE or FALSE

I Would Select all Data where Field1 is FALSE and Field2 is TRUE and Field3 is TRUE.

If i make:

SETRANGE(Field1,FALSE)
SETRANGE(Field2,TRUE)
SETRANGE(Field3,TRUE)

It doent's appears Data.

How must i code this ?

Here Example for Datarows:

. |Field1 | Field2 || Field3
1|False || TRUE || FALSE
2|False || FALSE|| TRUE
3|TRUE || TRUE|| FALSE
4|False || TRUE|| FALSE
5|TRUE || FALSE|| TRUE


I will select Row 1,2,4

But this don't work with:
SETRANGE(Field1,FALSE)
SETRANGE(Field2,TRUE)
SETRANGE(Field3,TRUE)

because after setting second SETRANGE there are not data for filtered the third SETRANGE.

hmmm
:-k :-k

Thanks
(Oo)=*=(oO)

Comments

  • SbhatSbhat Member Posts: 301
    Try this :

    SETFILTER(<Fieldname1>,'%1',false);
    SETFILTER(<Fieldname2>,'%1',true);
    SETFILTER(<Fieldname3>,'%1',true);

    SB.
  • elToritoelTorito Member Posts: 191
    No it does not work, the same result: Nothing :( but thanks for try.
    (Oo)=*=(oO)
  • SbhatSbhat Member Posts: 301
    You then have to use the CASE statement, i mean

    CASE <Field 1> begin
    <field 1> := true then
    <condition>
    CASE <Field 2> begin
    <field 2> := false then
    condition... and so on.

    SB.
  • elToritoelTorito Member Posts: 191
    Sbhat wrote:
    You then have to use the CASE statement, i mean

    CASE <Field 1> begin
    <field 1> := true then
    <condition>
    CASE <Field 2> begin
    <field 2> := false then
    condition... and so on.

    SB.

    hmm :-k
    Perhaps problem is that after the setrange i start a form like:

    FORM.RUN(50015);

    i would get filtered my data in the new form, #-o
    Perhaps i must use a SETTABLEVIEW ?

    But trying with:
    FORM.SETTABLEVIEW(Rec);

    it says me that variable SETTABLEVIEW is not defined

    ](*,)
    :-k

    The Form that i call have not source in property SourceTableView
    (Oo)=*=(oO)
  • awarnawarn Member Posts: 261
    Post your entire block of code so we can see it.

    -a
  • elToritoelTorito Member Posts: 191
    awarn wrote:
    Post your entire block of code so we can see it.
    -a

    In a Form(50005) i have a Button with C/AL COde in onPush Trigger (followCode)
    in Global Vars of Form 50005 i have an Variable "myRec" thats record Data Table 50011
    myRec.SETFILTER(FIELD1, '%1', TRUE); 
    myRec.SETFILTER("FIELD2", '%1', TRUE); 
    myRec.SETFILTER(FIELD3, '%1', TRUE); 
    
    // IF ROW FOUND
    IF myRec.FIND('-') THEN BEGIN
    
        // FORM.SETTABLEVIEW(myRec);
        // FORM.SETRECORD(myRec);
        FORM.RUN(50015);
    
    END ELSE BEGIN
    
      MESSAGE('No Data Found');
    
    END;
    
    
    

    Now i have follow idea, make a new field , a flowfield that checks if FIELD2 or FIELD3 is TRUE, and later (above) i must set only one filter to my new flowField. or similar, hmm :-k

    Thanks
    (Oo)=*=(oO)
  • SteveOSteveO Member Posts: 164
    Are you perhaps setting another filter elsewhere on the form?
    Try using myrec.RESET before setting the filters.

    Or perhaps make myrec a local variable?

    Also are you absolutely sure that there is data in the table that matches the criteria you are setting? (all 3 fields must be TRUE)??
    This isn't a signature, I type this at the bottom of every message
  • UrmasUrmas Member Posts: 76
    elTorito wrote:
    Here Example for Datarows:

    . |Field1 | Field2 || Field3
    1|False || TRUE || FALSE
    2|False || FALSE|| TRUE
    3|TRUE || TRUE|| FALSE
    4|False || TRUE|| FALSE
    5|TRUE || FALSE|| TRUE


    I will select Row 1,2,4

    But this don't work with:
    SETRANGE(Field1,FALSE)
    SETRANGE(Field2,TRUE)
    SETRANGE(Field3,TRUE)

    because after setting second SETRANGE there are not data for filtered the third SETRANGE.

    Sorry but I do not understand.

    How can you expect to receive any data if none of the lines of yoir dataset fit into your filter:
    Field1=FALSE AND Field2=TRUE AND Field3=TRUE
    ???
  • jmjm Member Posts: 156
    elTorito wrote:
    Here Example for Datarows:

    . |Field1 | Field2 || Field3
    1|False || TRUE || FALSE
    2|False || FALSE|| TRUE
    3|TRUE || TRUE|| FALSE
    4|False || TRUE|| FALSE
    5|TRUE || FALSE|| TRUE


    I will select Row 1,2,4

    But this don't work with:
    SETRANGE(Field1,FALSE)
    SETRANGE(Field2,TRUE)
    SETRANGE(Field3,TRUE)

    because after setting second SETRANGE there are not data for filtered the third SETRANGE.
    yes, you are right, all setranges will be executed.
    try it with:
    SETRANGE(Field1,FALSE)
    SETRANGE(Field2,FALSE,TRUE)
    SETRANGE(Field3,FALSE,TRUE)
    
    or with
    SETRANGE(Field1,FALSE)
    
    it looks like Field2,Field3 are not determining for your selection?

    br
    Josef Metz
    br
    Josef Metz
  • zarrynzarryn Member Posts: 29
    I may be off base here, but...
    Your sample data does not contain any record that matches the filters of Field1 = FALSE AND Field2 = TRUE AND Field3 = TRUE.
    IF you are trying to display all records where Field1 is FALSE OR Field2 is TRUE OR Field3 is TRUE then you might try the following...
    MyRec.RESET;
    IF MyRec.FIND('-') THEN
      REPEAT
         IF (MyRec.Field1 = FALSE) OR
            (MyRec.Field2 = TRUE) OR
            (MyRec.Field3 = TRUE)
         THEN
           MyRec.MARK(TRUE); 
      UNTIL MyRec.Next = 0;
    MyRec.MARKEDONLY(TRUE);
    FORM.RUN(50015,MyRec);
    
    If you need to restict the user from clearing the MARKEDONLY filter then set it inside a filtergoup. Hope this helps.
    Zarryn
  • randrewsrandrews Member Posts: 135
    elTorito wrote:
    myRec.SETFILTER(FIELD1, '%1', TRUE); 
    myRec.SETFILTER("FIELD2", '%1', TRUE); 
    myRec.SETFILTER(FIELD3, '%1', TRUE); 
    
    // IF ROW FOUND
    IF myRec.FIND('-') THEN BEGIN
    
        // FORM.SETTABLEVIEW(myRec);
        // FORM.SETRECORD(myRec);
        FORM.RUN(50015);
    
    END ELSE BEGIN
    
      MESSAGE('No Data Found');
    
    END;
    

    This will work exactly (i think), but i don't like MARK:

    Change
    myRec.SETFILTER(FIELD1, '%1', TRUE); 
    myRec.SETFILTER("FIELD2", '%1', TRUE); 
    myRec.SETFILTER(FIELD3, '%1', TRUE); 
    

    on
    myRec.SETFILTER(FIELD1, '%1', TRUE); 
    IF myRec.FIND('-')  THEN
        REPEAT
            myRec.MARK(TRUE);
        UNTIL myRec.NEXT =0;
    myRec.SETFILTER(FIELD1,''); 
    
    myRec.SETFILTER("FIELD2", '%1', FALSE); 
    IF myRec.FIND('-')  THEN
        REPEAT
            myRec.MARK(TRUE);
        UNTIL myRec.NEXT =0;
    myRec.SETFILTER(FIELD2,''); 
    
    myRec.SETFILTER(FIELD3, '%1', FALSE); 
    IF myRec.FIND('-')  THEN
        REPEAT
            myRec.MARK(TRUE);
        UNTIL myRec.NEXT =0;
    myRec.SETFILTER(FIELD3,''); 
    myRec.MARKEDONLY(TRUE)
    
  • elToritoelTorito Member Posts: 191
    hmm.

    Thanks first for you answers, for explain it more detailment, i can say, that in mysql i would did make it so:

    SELECT * FROM TABLE WHERE ((Field1=True) AND ((Field2=True) OR (Field3=True)))

    Now i would read and see your examples, and try to finish this my exercise
    (Oo)=*=(oO)
  • jmjm Member Posts: 156
    Hi,

    the correct code for your request is that from "zarryn" with a little modifications:
    MyRec.RESET; 
    IF MyRec.FIND('-') THEN 
      REPEAT 
         IF (MyRec.Field1 = FALSE) AND 
             ((MyRec.Field2 = TRUE) OR 
              (MyRec.Field3 = TRUE))
         THEN 
           MyRec.MARK(TRUE); 
      UNTIL MyRec.Next = 0; 
    MyRec.MARKEDONLY(TRUE); 
    FORM.RUN(50015,MyRec);
    

    br
    Josef Metz
    br
    Josef Metz
  • elToritoelTorito Member Posts: 191
    jm wrote:
    Hi,

    the correct code for your request is that from "zarryn" with a little modifications:
    br
    Josef Metz

    Hi, and Thanks you all =D> =D>
    Now i have it working and seems work 100% correct \:D/
    i don't have remember that can use Mark :oops: O:) :whistle:

    Well i get now finished my exercice and then drin k a cup of coffee of you slainte, cheers :wink:
    (Oo)=*=(oO)
Sign In or Register to comment.