Check If Field Exists, VBA Access
In this article I will explain how you can check if a field exists in an access database using VBA.
Previously in the article below I’ve explained how you can get the name of all the fields in a table in an access database using VBA:
I will be using the code in that article here.
Note: The example database used in this article has a table with the name “MyTable1“.
Note: In order to work with the Recordset object you may need to add reference to the Microsoft ActiveX Data Object Library. This has been explained in the article below:
The function below receives as input the name of a table and field. It checks if the field exists in the table:
It can be tested using the code below:
Note: If you do not wish to add reference to the Microsoft ActiveX Data Object Library you could use late binding to initiate the recordset object:
You can download the file and code used in this article from the link below: