The erro msg "Type mismatch in expression" appear when I run this code:
CDSIndicados.Filtered := False;
CDSIndicados.Filter := 'EDICOES_ID like ' + QuotedStr(IntToStr(Integer(cxComboBox1.Properties.Items.Objects[cxComboBox1.ItemIndex])));
CDSIndicados.Filtered := True;
I know this message may appear when there is an error in the data type of the field. But I could not fix. Was that it?
I'm suspecting that your
EDICOES_ID
field is an integer value, in which case you don't need to quote it in your filter expression and theLIKE
operator isn't supported AFAIK. If it is a string field, you do need the quotes andLIKE
is supported, but you typically want a wildcard in the expression as well. (LIKE is only supported for character (string) type fields. For numerics or dates, you need to use the usual comparison operators >, <, >=, <=, = or BETWEEN.)Do yourself a favor, too, and declare a local variable, and making sure that there's actually an item selected in the
ComboBox
before trying to access itsObjects
. I've added one both for theItemIndex
and for intermediate storage of the typecastObject
you're retrieving, which makes it much easier to debug if you need to do so.Here's a solution either way (whether it's an integer field, or a string that needs quoting).