Hi,
I just discovered, accidentally, that when running an update query in VBA code with SetWarnings turned off, any record with an error doesn't get updated. When I tested the update query by itself, the error message indicated there was a validation violation. But when checking every field in the design of the table, no fields had Validation Rules or Validation Texts.
I traced my problem to a text field, which contained data in the table to be updated, but the updating field was blank. Since the table's properties for that field included [Required = No] and [Allow Zero Length = No], I subsequently set the [Allow Zero Length = Yes]. That allowed the update to work.
My confusion is because I've read several suggestions indicating to not set the Allow Zero Length property to Yes.
There are several text fields in the update query and now because there was no warning, the possibility exists that many times those records were not updated when a field was to be changed from containing data to being empty. The update procedure has occurred monthly over many years. I shudder to think of corrupt data that may reside in the DB.
Is there any way to trap that kind of error without turning the SetWarnings on, which would cause a message to be displayed to the user?
Any suggestions will be greatly appreciated.
Vic
I just discovered, accidentally, that when running an update query in VBA code with SetWarnings turned off, any record with an error doesn't get updated. When I tested the update query by itself, the error message indicated there was a validation violation. But when checking every field in the design of the table, no fields had Validation Rules or Validation Texts.
I traced my problem to a text field, which contained data in the table to be updated, but the updating field was blank. Since the table's properties for that field included [Required = No] and [Allow Zero Length = No], I subsequently set the [Allow Zero Length = Yes]. That allowed the update to work.
My confusion is because I've read several suggestions indicating to not set the Allow Zero Length property to Yes.
There are several text fields in the update query and now because there was no warning, the possibility exists that many times those records were not updated when a field was to be changed from containing data to being empty. The update procedure has occurred monthly over many years. I shudder to think of corrupt data that may reside in the DB.
Is there any way to trap that kind of error without turning the SetWarnings on, which would cause a message to be displayed to the user?
Any suggestions will be greatly appreciated.
Vic