打印本文 打印本文 关闭窗口 关闭窗口
判断一个字段是否在表中的函数
作者:武汉SEO闵涛  文章来源:敏韬网  点击数810  更新时间:2009/4/22 20:22:22  文章录入:mintao  责任编辑:mintao

'判断一个字段是否在表中
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

打印本文 打印本文 关闭窗口 关闭窗口