1 (edited by sonixax 2022-04-08 23:50:01)

Topic: dbFilter not working!

Hi everyone,
I just have a problem with dbFilter in both Grid and combobox!!!

I want to filter results based on customer id. so Combo box or grid will show only records related to customer and not all of them.
I just want to do it in separate window (form) so I have to do that using scripts but its not working:(
if I write the filter manually in filter field of grid it will works but using script not working.

here is my script for both:

procedure Payment_OnShow (Sender: TObject; Action: string);
begin
   //Payment.ComboBox1.dbFilter := 'id_customers = ' + IntToStr(Payment.Save.dbParentTableId);
   Payment.ComboBox1.dbFilter := 'id_customers = 4';
end;
procedure Payment_OnShow (Sender: TObject; Action: string);
begin
    //Payment.TableGrid1.dbFilter := 'id_customers = ' + IntToStr(Payment.Save.dbParentTableId);
   Payment.TableGrid1.dbFilter :=  'id_customers = 4';
end;

how can I make it work?
I need one of them no matter which one.

There is a table called booking, I want to show all bookings related to customer in grid/combobox and select one of them in payment form to be able to add a payment for that certain booking.

Many many thanks

2 (edited by brian.zaballa 2022-04-09 03:03:10)

Re: dbFilter not working!

try running the dbupdate after your filter

Payment.ComboBox1.dbFilter := 'id_customers = 4';
Payment.ComboBox1.dbUpdate;

Payment.TableGrid1.dbFilter := 'id_customers = 4';
Payment.TableGrid1.dbUpdate;
brian

Re: dbFilter not working!

brian.zaballa wrote:

try running the dbupdate after your filter

Payment.ComboBox1.dbFilter := 'id_customers = 4';
Payment.ComboBox1.dbUpdate;

Payment.TableGrid1.dbFilter := 'id_customers = 4';
Payment.TableGrid1.dbUpdate;

Perfect, it works
many Thanks