Depending on the type of fields, and if it is not the right type, I display an error message (and I close the file)
But to test and despite the fact that I intentionally open the wrong file, I do not have a message that is displayed.
Is index 16 correct? Rather than referring to a field by its index it would be safer to refer to it by the fieldname:
if (Ann_New.FieldByName('Birthdate') = ftString) then
I also tested this coding, without result.
Yes, there are 17 fields in this file, and it is the last field.
I had found several codes on the internet to solve this problem, but none of them could work correctly. Either they generate a crash, or nothing happens.
I finally found the solution:
if (Ann_Old.FieldDefs.Items[16].DataType = ftDate) then
I can now decide based on the result of this test.
Thanks for your advice.