判断一个字段是否在表中的函数

时间:2009-07-11 01:45:00   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:br /> Set rs = CurrentDb.OpenRecordset(sTblName) rs.Fields.Refresh For Each fld In rs.Fields If fld.Name = sFldName Then BlnField = True Exit For End If Next rs.Close Set rs = Nothing Set fld = Nothing End Function Private Sub 命令0_Click() '返回True则有此字段,False则...
  正文:

判断一个字段是否在表中
Function BlnField(sTblName As String, sFldName As String) As Boolean

'sTblName 源表名
'要查找的字段名

Dim fld As Field
Dim rs As DAO.Recordset

BlnField = False
Set rs = CurrentDb.OpenRecordset(sTblName)
rs.Fields.Refresh
For Each fld In rs.Fields
If fld.Name = sFldName Then
BlnField = True
Exit For
End If
Next
rs.Close
Set rs = Nothing
Set fld = Nothing
End Function

Private Sub 命令0_Click()
'返回True则有此字段,False则无
MsgBox BlnField("tbl1", "ID")
End Sub
 



来源:http://www.002pc.com/master/College/Database/Access/2009-07-11/10023.html

收藏到:

关于《判断一个字段是否在表中的函数》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='98' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='98' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td