Function ifFieldExists(ByVal fieldName As String, ByVal TableName As String) As Boolean
Dim db As DAO.Database
Dim tbl As TableDef
Dim fld As Field
Dim strName As String
Set db = CurrentDb
Set tbl = db.TableDefs(TableName)
For Each fld In tbl.Fields
If fld.Name = fieldName Then
ifFieldExists = True
Exit For
End If
Next
End Function
Execution Process:
If ifFieldExists("INDC", "Import_process") Then
Else
db.Execute "Alter table Import_process add column INDC text"
End If
Dim db As DAO.Database
Dim tbl As TableDef
Dim fld As Field
Dim strName As String
Set db = CurrentDb
Set tbl = db.TableDefs(TableName)
For Each fld In tbl.Fields
If fld.Name = fieldName Then
ifFieldExists = True
Exit For
End If
Next
End Function
Execution Process:
If ifFieldExists("INDC", "Import_process") Then
Else
db.Execute "Alter table Import_process add column INDC text"
End If
No comments:
Post a Comment