Filter button created to make the filter on the FORM Answered

Filipe

I created a button in the Production Advance so that I could filter the rows AG01, AG02, AG03, .. AG09.
However, when performing the filter procedure, you can only do it in the last and first.

 

my code:

 

windowevent start

create=button=name=Filtrar,menutext=Filtrar,text=Filtrar

end event


windowevent click Filtrar


declare=lform=ue_form

lform.dwname=FiltrarOperação
lform.sql=select space(30) rota1, space(30) rota2, space(30) rota3, space(30) rota4, space(30) rota5, space(30) rota6, space(30)rota7, space(30) rota8, space(30) rota9 from "BEAS_DUMMY"
where
lform.dw_1.item.Rota1.title=Rota 1
lform.dw_1.item.Rota2.title=Rota 2
lform.dw_1.item.Rota3.title=Rota 3
lform.dw_1.item.Rota4.title=Rota 4
lform.dw_1.item.Rota5.title=Rota 5
lform.dw_1.item.Rota6.title=Rota 6
lform.dw_1.item.Rota7.title=Rota 7
lform.dw_1.item.Rota8.title=Rota 8
lform.dw_1.item.Rota9.title=Rota 9
lform.style=edit
lform.showdialog

dw_1.setfilter=item.ag01='<lform.rota1>'
dw_1.setfilter=item.ag02='<lform.rota1>'
dw_1.setfilter=item.ag03='<lform.rota3>'
dw_1.setfilter=item.ag04='<lform.rota4>'
dw_1.setfilter=item.ag05='<lform.rota5>'
dw_1.setfilter=item.ag06='<lform.rota6>'
dw_1.setfilter=item.ag07='<lform.rota7>'
dw_1.setfilter=item.ag08='<lform.rota8>'
dw_1.setfilter=item.ag09='<lform.rota9>'


//dw_1.setfilter=item.ag07='MONTAGEM-7'

end event

destroy=lform

//Principal Form

 

GLOBAL FUNCTION FormClose


form.return.setvar=rota1=<dw_1.item.rota1.value>
form.return.rota1=1

form.return.setvar=rota2=<dw_1.item.rota2.value>
form.return.rota2=1

form.return.setvar=rota3=<dw_1.item.rota3.value>
form.return.rota3=1

form.return.setvar=rota4=<dw_1.item.rota4.value>
form.return.rota4=1

form.return.setvar=rota5=<dw_1.item.rota5.value>
form.return.rota5=1

form.return.setvar=rota6=<dw_1.item.rota6.value>
form.return.rota6=1

form.return.setvar=rota7=<dw_1.item.rota7.value>
form.return.rota7=1

form.return.setvar=rota8=<dw_1.item.rota8.value>
form.return.rota8=1

form.return.setvar=rota9=<dw_1.item.rota9.value>
form.return.rota9=1

end global

Comments

2 comments

  • Comment author
    Martin Heigl
    • Edited
    • Official comment

    Hi Filipe

    you don't need the GLOBAL FUNCTION FormClose
    You can define the filter always only 1 time. With next definition you overwrite the other filter definition

    Idea:

    Create the filter string and then set it

     

    declare=lform=ue_form

    lform.dwname=FiltrarOperação
    lform.sql=select space(30) rota1, space(30) rota2, space(30) rota3, space(30) rota4, space(30) rota5, space(30) rota6, space(30)rota7, space(30) rota8, space(30) rota9 from "BEAS_DUMMY"
    lform.dw_1.item.Rota1.title=Rota 1
    lform.dw_1.item.Rota2.title=Rota 2
    lform.dw_1.item.Rota3.title=Rota 3
    lform.dw_1.item.Rota4.title=Rota 4
    lform.dw_1.item.Rota5.title=Rota 5
    lform.dw_1.item.Rota6.title=Rota 6
    lform.dw_1.item.Rota7.title=Rota 7
    lform.dw_1.item.Rota8.title=Rota 8
    lform.dw_1.item.Rota9.title=Rota 9
    lform.style=edit
    lform.showdialog

    // create filter string
    setvar=ls_filter=
    if <lform.rota1> <> "" then
    addvar=ls_filter= or item.ag01='<lform.rota1>'
    end if
    if <lform.rota2> <> "" then
    addvar=ls_filter= or item.ag01='<lform.rota2>'
    end if
    // same for all other


    if <ls_filter> <> "" then
    // messagebox=<ls_filter,mid 4>
    // now set filter without first "or"
    dw_1.setfilter=<ls_filter,mid 4>
    end if
    destroy=lform

  • Comment author
    Filipe
    thank you it worked!
    0

Please sign in to leave a comment.