Topic: combobox filter
Can I filter a combobox where the user is logged in? frmLessonLIST.combobox1.dbFilter:='id_users='+IntToStr(idUser);
I have successfully used dbFilter for tablegrid but this doesn't seem to work for combobox.
var
idUser: integer = -1
procedure frmLogin_Button1_OnClick (Sender: string; var Cancel: boolean);
var
s: string;
begin
// SQL query for check user and password
s := VarToStr(SQLExecute('SELECT count(id) FROM users WHERE (id = ' + frmLogin.ComboBox1.sqlValue + ') AND (password = ''' + frmLogin.edPassword.Text + ''');'));// if SQL query found login and password
if (s <> '0') and (s<>'') then
begin
idUser := frmLogin.ComboBox1.dbItemID; // remember user id// check admin rights
s := VarToStr( SQLExecute('SELECT administrator FROM users WHERE (id = '+ frmLogin.combobox1.sqlValue + ');') );
if s='0' then // if the user does not have administrator privileges, deactivate the button to create other users
begin
frmLessonLIST.tablegrid1.dbFilter:='id_users='+IntToStr(idUser); // show records according to user loginend;