Topic: Best way of filtering

Hello all,


I was wondering if you would do this some other way or not.


I have a simple form, with a Combobox, an Edit Box, a Button and a Tablegrid.


The Combobox is filled based on a table that has hundreds of entries so to help the user find what he wants, he can type in the Edit a few letters that will filter the combobox.

Then he makes his choice and presses the button to diplay result in Tablegrid.


Everything works fine with this code for pre-filtering of the Combobox.


procedure Form1_ComboBox1_OnDropDown (Sender: string);

var
    like : String;
begin
    like := Form1.Edit1.Text;
    if like = '' then
        begin
            Form1.ComboBox1.dbSQLExecute('SELECT id, artist_name FROM artist' );
        end
     else if like <> '' then
         begin
            Form1.ComboBox1.dbSQLExecute('SELECT id, artist_name FROM artist WHERE artist_name LIKE "%'+like+'%"' );
        end;
end;

But then I noticed the "Filter" property of the Combobox in the Object Inspector. Do you use this to pre-filter you comboboxes are is it something completely different ?


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Best way of filtering

The combobox filter property can only handle one filter at a time, I tried 2 and it does not work, the application crashes. I use it mostly to pre-filter the results shown in the combobox (e.g: id_something=2 to only show results having id_something set to 2). It is more or less a restriction in the results shown.

By the way, current English online documentation is in Russian for this property smile http://myvisualdatabase.com/help_en/

Re: Best way of filtering

Merci Tcoton for your answer.


So no way of using this filtering property with variables or {Edit1} statement... ?


Hmmm, I'll stik to my query. I just hope it's not to heavy on the sQL engine.


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Best way of filtering

mathmathou
May be this example will be useful for you, search directly in ComboBox:
http://myvisualdatabase.com/forum/misc. … download=1

Dmitry.

Re: Best way of filtering

Thanks Dmitry !!


I'll defenetly give this technique a try !!


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor