Board index » delphi » MS Access "Required" and/or "Allow Zero-Length" AND Delphi TField.Clear

MS Access "Required" and/or "Allow Zero-Length" AND Delphi TField.Clear

I have an MS Access .mdb which has many tables which have many "Text" fields
defined as "Required = No" and "Allow Zero Length = No".  I have created a
Delphi .exe to allow editing of these tables by using the DbCtrls,
TDatasource, TQuery, and TDatabase.  If a field contains non-blank data, and
I attempt to update it to "empty", upon Posting, I get the error
"Zero-Length not allowed".  I tried trapping the OnChange event to set the
TField of the Dataset to Null by using the TField.Clear method.  I also
tried simply setting TField.AsVariant = Null, with the same results.  If I
change the table definition to "Allow Zero-Length = Yes", everything works
fine ... except I already have an MS Access UI which uses many queries which
use IIF(IsNull(field)).  I would like to avoid having to search through all
the queries looking for these instances and changing them to
IIF(IsNull(field) or field = "").

This seems to me to be a driver issue.  I'm using the Native MSACCESS driver
in Delphi 4 CS.  The fact that I cannot set a field's value to Null seems to
be very inappropriate to me.

I would appreciate any information regarding this situation whether it be "a
new driver is in the works" or "we simply don't support null values for MS

Thank you.


Re:MS Access "Required" and/or "Allow Zero-Length" AND Delphi TField.Clear

My Recordset Component has a Feature "Set Empty Strings as NULL Values"
which works around the Problem you have.


Other Threads