` Printed Icetips Article

Icetips Article



ABC: Resetting filters
2001-04-17 -- Richard Rose
 
Newsgroups: softvelocity.products.c55ee

This is an actual working filter
BRWx.ApplyFilter Priority 4500 (before the parent call)

!On Order|#1|Allocated|#3|BookedIn|#5|BookedOut|#6|Adjustment|#7
If AdjustmentTypeFilter = 1
    BRW1.SetFilter('ADJ:Type = 1','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 2
    BRW1.SetFilter('ADJ:Type = 2','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 3
    BRW1.SetFilter('ADJ:Type = 3','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 4
    BRW1.SetFilter('ADJ:Type = 4','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 5
    BRW1.SetFilter('ADJ:Type = 5','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 6
    BRW1.SetFilter('ADJ:Type = 6','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 7
    BRW1.SetFilter('ADJ:Type = 7','1AdjustmentType')
ElsIF AdjustmentTypeFilter = 8
    BRW1.SetFilter('','1AdjustmentType')
END

I can reset the browse two ways, I can make the drop down list box
(AdjustmentTypeFilter) a reset field so whenever its changed so does the
browse filter which inturns resets the browse contents, or I hit a refresh
button. In my case I use a refresh button becuase this is not the only thing
I'm filtering on.

RefreshButton.Accepted embed
BRW1.ResetSort(1)        !Unconditionally updatethe browse
BRW1.UpdateWindow    !Write the browse to the window control


If you want to know how to "filter" in a many to many situation (1:M M:1)
let me know. thats different and more involved and isn't perhaps really a
filter.

hth

Richard


Editors note:

It would be fairly easy to shorten the filter building code to something like:

!On Order|#1|Allocated|#3|BookedIn|#5|BookedOut|#6|Adjustment|#7
If Inrange(AdjustmentTypeFilter,1,7)
  BRW1.SetFilter('ADJ:Type = ' & AdjustmentTypeFilter,'1AdjustmentType')
ElsIF AdjustmentTypeFilter = 8
    BRW1.SetFilter('','1AdjustmentType')
End



>   
> 'I feel your pain'!!  I too have spent untold hours getting
> what used to be 'canned' stuff to work properly in ABC.
>
> I currently have the same type problem with a filter on
> a simple browse of a TPS file.  A simple lookup file
> with update also.  When Called as a lookup I want
> it to filter out items that don't have a matching
> first key element.  This element is provided by
> a global variable which is assigned to a local
> variable at program init.  (Loc:Unit)
> When the browse is called as a lookup the
> filter works fine and the appropriate records
> are displayed.  If the browse is called for
> update, it displays NO records.
> Here is the Filter expression, which I've
> used hundreds of times before without
> fail.  (All variables are Bound)
>
> ((LOC:UNIT <> '' AND JOT:UNIT = LOC:UNIT)
> OR (LOC:UNIT = '' AND JOT:UNIT <> LOC:UNIT))
>
> ALL fields XXX:UNIT are STRING(2).
>
> Normally at program setup I'd just assign :
>     LOC:UNIT = T:UNIT
>
> But I have also tried this:
>
> IF T:UNIT = ''
>   LOC:UNIT = ''
>  ELSE
>   LOC:UNIT = T:UNIT
> END
>
> Where T:UNIT is the Global variable used
> to filter on lookup.  JOT:UNIT is the first
> Element of the key and defined the same.
> When passed to the filter the filter works.
> When no global variable exists the
> browse should display all records but
> comes up empty.
>
> Does anyone know what I'm missing here?
> Why is the browse comming up with no
> records found?
> I've tested all variables and if LOC:UNIT
> = '' the browse should display all records
> but doesn't.
> It's probably something simple but I
> can't see it.
>
> My workaround has been to go to the embed
> points where the filter expression is and
> bypass it.  I manually create an IF/THEN
> expression setting the filter depending on
> what value LOC:UNIT has.
> This works but shouldn't be necessary.
> Any ideas anyone?
>
> Thanks to all.
>
> Joe
>
>
> Don Childers wrote:
>
> > Okay, I'm trying to implement a very straight-forward filter on a
> > table...
> >
> > 'EMP:DPTSysID = CurrentDepartment OR CurrentDepartment = 0'
> >
> > Unfortunately, I'm trying to do it in an ABC Browse, and I'm starting
> > to suspect that ABC and SQL are a plot by a bunch of gearheads here and
> > none of it works.
> >
> > First off, I tried to get just the first part of the filter working
> > 'EMP:DPTSysID = CurrentDepartment'
> >
> > using the techniques that Steve Parker used in his second Dynamic
> > Filters article.  I followed those directions EXACTLY, as shown in
> > Figure 3 and 4, for setting up a filter based on a drop down list box.
> > I used a list box control template, and assigned the selected value to
> > CurrentDepartment.  In the File Drop's Accepted embed. I placed
> > ThisWindow.Reset(1) as Steve instructed.  I KNOW that CurrentDepartment
> > changes, because I'm using 0{Prop:Text} to display it on the title of
> > the browse.  BUT THE STUPID BROWSE NEVER REFRESHES!!!!!!!!!!!!!  The
> > browse starts off empty, and the first department selection I make
> > displays the proper records in the browse, but any additional
> > department selections don't effect the browse at all!!!!!!!!!!!!
> >
> > As best I can tell, ThisWindow.Reset(1) does absolutely nothing!!!!!!!!
> > However, if I select the SECOND tab on the browse, the browse
> > refreshes, so if I alternate selecting a new department with selecting
> > a different sort order tab, it works fine.
> >
> > WHAT IS THE PROBLEM WITH ABC!!!!   WHY is it SO FRICKING HARD to get
> > anything to work consistently.  I HAVE implemented the SAME code Steve
> > shows in his article on a different browse, and the damned thing does
> > not work the same way!!!!!!!!!!!!!!!!!
> >
> > This is titled Chapter 1 because I've been around the bend with this
> > stupid browse a dozen different times, and I know after somebody tells
> > me the stupid mistake I made implementing this portion of the filter,
> > there will be additional chapters trying to get the rest of the filter
> > working.
>



Printed November 23, 2024, 2:21 am
This article has been viewed/printed 35424 times.
Google search has resulted in 41 hits on this article since January 25, 2004.