Unanswered: Verify existence of a field in a table
I have an application that has been distributed to several users in an organisation over time. I want to check that a certain table contains a certain field as the data tables have evolved. The aplication is in an MDE with links to data tables in an MDB. I want to make sure the user is not using an outdated data file.
I have figured out how to verify the existence of a table, but how to do the same for a field?
Function FieldExists(ByVal TableName As String, ByVal FieldName As String) As Boolean
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set dbs = CurrentDb
Set tdf = dbs.TableDefs(TableName)
For Each fld In tdf.Fields
If fld.Name = FieldName Then
FieldExists = True
Set fld = Nothing
Set tdf = Nothing
Set dbs = Nothing