var CheckSet: Set of Byte; ... begin ... CheckSet := [1..5]; randomize; repeat c1:=RandomRange(1,5); Exclude(CheckSet, c1); until (not AdoTable1.Locate('c1',c1,[loCaseInsensitive])) or (CheckSet = []); ... end;