` Printed Icetips Article

Icetips Article



Par2: Multiple locator fields
1998-10-21 -- Dennis Evans
 
(Also see related article by Charles Bolland)

>I have recently converted my CW2003 App to CW4/ABC.  It contains
>thousands of names and addresses.  Many of the names are common names such
as "Jones" and "Smith".
I want to  use two locator fields in my browse so that I can
>first locate for example "Jones" and then narrow the search by locating
>the first name for Jones.

   First, have you considered a FilterLocator?  If that will not
work the way you want or need then the following will at least get things
started.

   This is not a true locator, ie the user can not just start typing as in
the actual locators but it will find the records you are looking for.

You will need two local variables to store the user input.

Place the local variables on the screen for user input.

In the control event handling accepted the default priority will work,

for Loc:Lname

if Loc:Lname
  Do FindIt         ! call to local routine, can be a procedure if you want
end

for the Loc:FName
if Loc:FName
    ! make sure there is something in the LName
    if Loc:Lname
       do FindIt
    else
       select(?Loc:Lname)
    end
end  !if

Create a local routine/procedure

FindIt                routine

if Loc:LName
   Dat:LName = Loc:LName
   ! if first name has a value include
   ! if no value blank record buffer
   if Loc:FName
       Dat:FName = Loc:Fname
       Loc:Fname = ''                         ! clear for next pass
   else
       Dat:FName = ''
   end
   BrowseName.ResetFromBuffer()        ! reset the browse
end ! if

exit         ! end of routine

May not be exactly what you are looking for, it will find the correct
record,  but should get you started in the right direction.

Notes,

   Deriving the entry locator class to this should not be all that
difficult.

   The ResetFromBuffer method resets the browse based on the
current record buffer.

   This can also be used on a browse with no key that is sorted by
the view order property.

   The record buffer will be updated when the browse resets.

On report of a problem when locator type was "Entry," Dennis noted:

Just for the heck of it try setting the locator type to "None."

The code should be used to replace an entry locator, not use in conjunction with.

The step locator will work at the same time because of the way the take key
method in the browse class calls the locator.



Printed May 4, 2024, 11:05 am
This article has been viewed/printed 35115 times.