How to verify if a field is present in a table

  • Thread starter Thread starter felixc36
  • Start date Start date
F

felixc36

Hi,

I have a project where i need to verify the existence of a field in a table
before doing the next step.
I know how to crate tables with the Tabledef object and Field object but i
just don t know how t retrieve the fieldname of an existing table.

Anyone can tell me how i can do this?

Thank you in advance

Dan
 
I have a project where i need to verify the existence of a field in a table
before doing the next step.
I know how to crate tables with the Tabledef object and Field object but i
just don t know how t retrieve the fieldname of an existing table.

Several ways, the one I don't like is to just go ahead and
use the field and use error trapping to detect when it isn't
there.

I think a better method is to iterate through the TableDef's
(or Recordset's) Fields collection and check if it's there>

BolFieldExists = False
For Each fld In tdf.Fields
If fld.name = "thefieldname"
BolFieldExists = True
Exit For
End If
Next fld
If BolFieldExists Then
' ok to proceed
Else
' not there
End If
 
Back
Top