|
'=========================================================================================
'函數(shù)名稱: IsExistField
'功能描述: 檢測表中是否存在某個字段
'輸入?yún)?shù): sTableName 必需的,表名稱。
' sFieldName 必需的,檢測的字段名稱
'返 回 值: true或者false
'使用示例: IsExistField("訂單表","訂單日期")
'作 者: 金宇
'創(chuàng)建日期: 2012-12-16
'=========================================================================================
Public Function IsExistField(ByVal sTableName As String, ByVal sFieldName As String) As Boolean
On Error GoTo ErrorHandler
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
|
本帖子中包含更多資源
您需要 登錄 才可以下載或查看,沒有帳號?注冊
x
|