設為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 2149|回復: 1
打印 上一主題 下一主題

[模塊/函數(shù)] 判斷表中是否存在某個字段的函數(shù)

[復制鏈接]
跳轉到指定樓層
1#
發(fā)表于 2012-12-17 14:12:54 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
'=========================================================================================
'函數(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
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 分享淘帖 訂閱訂閱
2#
發(fā)表于 2012-12-17 19:27:56 | 只看該作者
本帖最后由 todaynew 于 2012-12-17 19:29 編輯

{:soso_e120:}
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2024-10-23 08:38 , Processed in 0.159812 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表