@wp thanks, but unfortunately that code didn't work. I've tested on Lazarus 2.2.2 32 bit on Windows.Strange, I had tested it before posting, and it had worked. But anyway, korba812's solution is much better because input validation should not be performed by the visual controls but by the database itself.