|
'这是本人写的两个检测表是否存在的一个自定义函数,仅供参考
Public Function Btbl (strTblName As String) As Boolean
Dim I As Integer
Dim tdf As TableDef
Btbl=False
'遍历所有表,判断指定表名是否存
For I = 0 To CurrentDb.TableDefs.Count - 1
If CurrentDb.TableDefs(I).Name = strTblName Then
Btbl =True '存在则真
Exit for
End If
Next I
End Function
'代码也可以这样写
Public Function Btbl (strTblName As String) As Boolean
Dim I As Integer
Dim tdf As TableDef
Dim M_Count As Intrger
'判断指定表名是否存
For I = 0 To CurrentDb.TableDefs.Count - 1
If CurrentDb.TableDefs(I).Name = strTblName Then
M_count=M_count+1
End if
Next I
'输入值真则存,假则不存在
If M_count > 0 then
Btbl = True
Else
Btbl = False
End if
End Function
[ 本帖最后由 tanhong 于 2008-6-21 09:34 编辑 ] |
|