'判断一个字段是否在表中
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
新闻热点
疑难解答