Author Topic: [SOLVED] Catching TField.Required  (Read 180 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 3595
[SOLVED] Catching TField.Required
« on: September 25, 2026, 10:46:39 am »
Hi Folks,

Laz4.3/FPC3.2.3-64 Bit
Target Win64

I have a DBGrid with a connected Datasource on a SQLite Database, and a connected DBNavigator

in the DB are columns with Constraint "NOT NULL", which propagates back to the Dataset resp. the corresponding TField.

How can i catch the Exception, if the User "forgets" to provide a value for a required field in the DBGrid?
What i do know, is that the Exception occurs BEFORE trying to write to the DB (since i actually do have some Try/Excepts in a few places).

Basically: Where do i have to put the Try/Except to catch that blasted thing?

Or maybe even better: Is there an Event onException or something?
And no: Application.OnException is not really solution
« Last Edit: September 25, 2026, 11:08:57 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Zvoni

  • Hero Member
  • *****
  • Posts: 3595
Re: Catching TField.Required
« Reply #1 on: September 25, 2026, 10:50:10 am »
Aha!

TDataSet has some "OnXXXXError"-Events

Investigating now....

Where is my bullwhip and Fedora-hat?...
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Zvoni

  • Hero Member
  • *****
  • Posts: 3595
Re: Catching TField.Required
« Reply #2 on: September 25, 2026, 11:08:43 am »
OK,
solved.

Use onPostError, and set DataAction to daAbort --> EAbort to be ignored in Project-Options - Language Exceptions (and "Don't notify on Exceptions")
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018