Listed, I'm extracting data from a jet db, and I occasionally get crippling errors when a field is null. What's the best way of dealing with this - do I really need to put an "If not isnull(" thing in EVERY line, just in case?
Printable View
Listed, I'm extracting data from a jet db, and I occasionally get crippling errors when a field is null. What's the best way of dealing with this - do I really need to put an "If not isnull(" thing in EVERY line, just in case?
The best way, of course, is not to put any null values in your database :D
I think using IsNull() is the only easy way out. Of course, you can do one thing: omit this validation for those fields which cannot be null. But otherwise, you don't have much option.
Damn.
Yup.
If you can edit the database, remove all Null values and modify the design and give everything default values, that way you can never get a null anymore.
Or write a function which will give you the value of the database, or when it was null, a default value ("" for strings, 0 for numeric, etc)
But yeah it sucks....
If your errors are occuring because you are displaying the record data to a textbox (or simular)....
Do this:
Code:
Text1.Text = "" & rst!fieldname
hahaha, Halloween is definitely approaching ... old posts arising from the dead. :p