Topic: if dbitemid not equal

Hey guys, what am i doing wrong?
i want this to change color if both comboboxes are different.

begin
   if frmassistencia.cbcriacaolocal.dbItemID <> frmassistencia.cbtransferido.dbitemid
  then
  begin
  frmassistencia.cbcriacaolocal.Color := clred
  end;

Re: if dbitemid not equal

Hello Vasco,


I think your logic is correct, but in order to "activate" the color change, you need to put it into an event that would trigger the logic.


Did you pout your code in the OnChange event or OnClick event of the combobox ?


Math

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

Zaza Gabor

Re: if dbitemid not equal

yes, on "on show"

Re: if dbitemid not equal

In addition to the OnShow event, you also need to place your code on the OnChange event as Math pointed out for both comboxes. And you should have an else along with it so it catches when it's equal such as


if frmassistencia.cbcriacaolocal.dbItemID <> frmassistencia.cbtransferido.dbitemid then
    frmassistencia.cbcriacaolocal.Color := clred else frmassistencia.cbcriacaolocal.Color := clDefault

If you want to color the text only, you can do the following

frmassistencia.cbcriacaolocal.Font.Color := clred else frmassistencia.cbcriacaolocal.Font.Color := clDefault

Re: if dbitemid not equal

Weird, only the font solution worked...
Many thanks EhWagner smile