Subject Re: Grid
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 23 Jul 2020 09:07:20 +0200
Newsgroups dbase.getting-started

On 2020-07-23 07:01, Tony Hughes wrote:
> Hi All,
> I have a grid set up in my code with about 130 coded products - Code like PWD039 - LIQ063 etc which are codes for raw material chemicals - Can I add say an entry field to one side/ bottom that I can enter the above codes and it finds that record in the grid. I am doing this in other functions throughout the form, but can't seem to do it with the grid that I have running ?  The Table is indexed on "Stock Code" which holds the above mentioned codes - Tony h
>

The short answer is yes. :-)  dBASE comes with seeker.cc which is a
custom entryfield.  This does, however, only work if you are using query
objects to access your tables.

As an aside, you should avoid spaces in fieldnames and you should also
avoid using reserved words as fieldnames. (There's a list in the help
file.)  They can be dealt with but it becomes a nuisance.

To place a seeker control on your form enter the following in the
Command panel.

set procedure to :formcontrols:seeker.cc

The seeker needs an index built on upper(fieldname) so in the Command panel

use mytablename exclusive
index on upper(:stock code:) tag stock_code
use

Open your form in the designer.  In the Components Palette select the
tab "Form Controls"  (use the little black left and right arrows if it
isn't visible) and drag the seeker onto the form

Select your rowset in the Inspector and assign stock_code to the index
property.

If you have more than one query object on the form use F12 to open the
sourcecode editor.  At the bottom of the constructor code and before the
event handler functions there will be a line something like

      this.rowset =  this.stock1.rowset

A seeker uses the rowset assigned to the form's rowset property and only
on rowset can be assigned at any given time.  Make sure this line
assigns the correct rowset to the form's rowset property.  Change it if
necessary.

Because you are using an index your stock codes will appear in
alphabetical order.  As you type in a code the rowpointer will
automatically move to the first record that matches the characters
already entered.  Characters can be entered in upper or lower case.


Mervyn.