点击下载此示例
Public Function IsExistField(ByVal sTableName As String, _
ByVal sFieldName As String) As Booleanler
Dim fld As Field
Dim rs As DAO.Recordset
IsExistField = False
Set rs = CurrentDb.OpenRecordset(sTableName)
For Each fld In rs.Fields
If fld.Name = sFieldName Then
IsExistField = True
Exit For
End If
Next
rs.Close
Set rs = Nothing
Set fld = Nothing
ExitHere:
Set rs = Nothing
Set fld = Nothing
Exit Function
ErrorHandler:
MsgBox Err.Description, vbInformation, "提示"
Resume ExitHere
End Function
使用示例: IsExistField("订单表","订单日期") '检测订单表中是否有订单日期字段