设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

1970-1-1 08:00| 发布者: harsonliao| 查看: 2765| 评论: 0

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

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-5-18 23:03 , Processed in 0.070168 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部