Subject |
Re: FILTER |
From |
Mustansir Ghor <mustan31@hotmail.com> |
Date |
Sat, 25 Mar 2017 16:20:20 -0400 |
Newsgroups |
dbase.getting-started |
Dear Mervyn
Thanks. it worked.
Since append was to be done from an active grid where filter was to be applied after user entered the data, I wonder if parameter query would have worked.
Regards
Mustansir
Mervyn Bick Wrote:
> On 2017-03-23 10:03 PM, Mustansir Ghor wrote:
> > Dear all
> >
> > I am using updateset to append a rowset2 from rowset1. I have applied filter condition to rowset1 and after beginfilter() statement, when I append, all records of rowset1 are appended to rowset2.
> >
> > Any leads on this logical error how to rectify so that only filter records can be appended.
> >
> > best Regards
> > Mustansir
> >
>
> When I first read your message my immediate reactions was "That's what I
> would expect. The filter doesn't change the actual rowset, it simply
> hides the rows it doesn't want. The rowset, as used by updateset, is
> still the full rowset."
>
> Although I do use filters on occasion I normally use parameter driven
> queries as they are more flexible and I have never had a problem with
> the updateset class.
>
> As an aside, I seldom use the copy() method of the updateset class.
> Instead I use the SQL select * from table where ... save to whatever.
> This overwrites the existing table so it can't be used where one needs
> to append to an existing table.
>
> Before replying to your message I set up a little test form and I found
> that updateset DOES respect the filter. Have a look at the code in the
> example form and compare it with your own code.
>
> Before you run the attached example form you will need to open it in the
> sourcecode editor and edit the path to library.dbf if necessary.
>
> Mervyn.
>
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 2017-03-24
> //
> parameter bModal
> local f
> f = new test_filterForm()
> if (bModal)
> f.mdi = false // ensure not MDI
> f.readModal()
> else
> f.open()
> endif
>
> class test_filterForm of FORM
> with (this)
> height = 34.8182
> left = 6.0
> top = 1.7273
> width = 149.5714
> text = ""
> endwith
>
> this.LIBRARY2 = new QUERY(this)
> with (this.LIBRARY2)
> left = 2.0
> top = 32.0
> sql = 'select * from "D:\dUFLP11\Library.DBF" where whatitis like :what'
> params["what"] = "%"
> active = true
> endwith
>
> this.LIBRARY1 = new QUERY(this)
> with (this.LIBRARY1)
> left = 47.0
> top = 32.0
> sql = 'select * from "D:\dUFLP11\Library.DBF"'
> active = true
> endwith
>
> this.GRID1 = new GRID(this)
> with (this.GRID1)
> dataLink = form.library1.rowset
> height = 22.5
> left = 4.0
> top = 1.0
> width = 63.0
> endwith
>
> this.GRID2 = new GRID(this)
> with (this.GRID2)
> dataLink = form.library2.rowset
> height = 22.5
> left = 84.0
> top = 1.0
> width = 63.0
> endwith
>
> this.PUSHBUTTON1 = new PUSHBUTTON(this)
> with (this.PUSHBUTTON1)
> onClick = class::PUSHBUTTON1_ONCLICK
> height = 1.0909
> left = 24.0
> top = 26.0
> width = 15.2857
> text = "Filter"
> endwith
>
> this.PUSHBUTTON2 = new PUSHBUTTON(this)
> with (this.PUSHBUTTON2)
> onClick = class::PUSHBUTTON2_ONCLICK
> height = 1.0909
> left = 105.0
> top = 26.0
> width = 15.2857
> text = "Select"
> endwith
>
> this.ENTRYFIELD1 = new ENTRYFIELD(this)
> with (this.ENTRYFIELD1)
> height = 1.0
> left = 61.0
> top = 26.0
> width = 24.0
> value = "File Method"
> endwith
>
> this.PUSHBUTTON3 = new PUSHBUTTON(this)
> with (this.PUSHBUTTON3)
> onClick = class::PUSHBUTTON3_ONCLICK
> height = 1.0909
> left = 24.0
> top = 29.0
> width = 15.2857
> text = "Clear Filter"
> endwith
>
> this.PUSHBUTTON4 = new PUSHBUTTON(this)
> with (this.PUSHBUTTON4)
> onClick = class::PUSHBUTTON4_ONCLICK
> height = 1.0909
> left = 105.0
> top = 29.0
> width = 15.2857
> text = "Show all"
> endwith
>
> this.PUSHBUTTON5 = new PUSHBUTTON(this)
> with (this.PUSHBUTTON5)
> onClick = class::PUSHBUTTON5_ONCLICK
> height = 1.0909
> left = 24.0
> top = 32.0
> width = 15.2857
> text = "Update filter1"
> endwith
>
> this.PUSHBUTTON6 = new PUSHBUTTON(this)
> with (this.PUSHBUTTON6)
> onClick = class::PUSHBUTTON6_ONCLICK
> height = 1.0909
> left = 105.0
> top = 32.0
> width = 15.2857
> text = "Update filter2"
> endwith
>
> this.rowset = this.library1.rowset
>
> function PUSHBUTTON1_onClick()
> form.library1.rowset.filter = "whatitis = '"+form.entryfield1.value+"'"
> return
>
> function PUSHBUTTON2_onClick()
> form.library2.params['what'] = form.entryfield1.value+'%'
> form.library2.requery()
> return
>
> function PUSHBUTTON3_onClick()
> form.library1.rowset.filter = ''
> return
>
> function PUSHBUTTON4_onClick()
> form.library2.params['what'] = '%'
> form.library2.requery()
> return
>
> function PUSHBUTTON5_onClick()
> u = new UpdateSet()
> u.source = form.library1.rowset
> u.destination = "filter1.dbf"
> u.copy()
> u = null
>
> return
>
> function PUSHBUTTON6_onClick()
> u = new UpdateSet()
> u.source = form.library2.rowset
> u.destination = "filter2.dbf"
> u.copy()
> u = null
> return
>
> endclass
>
>
|
|