判断对象是否存在数据库中的模块
时间:2006-10-22 21:37 来源:Access开发者 作者:想不通 阅读:次
一组判断对象是否存在数据库中的模块
----判断查询是否存在------------------
Function IsQueryInDatabase(strQueryName As String) As Integer
Dim db As DAO.Database
Dim I As Integer
Set db = CurrentDb
IsQueryInDatabase = False
db.QueryDefs.Refresh
For I = 0 To db.QueryDefs.Count - 1
If strQueryName = db.QueryDefs(I).Name Then
'查询存在
IsQueryInDatabase = True
Exit For
End If
Next I
Set db = Nothing
End Function
'----判断表是否存在------------------
Function IsTableInDatabase(strTableName As String) As Integer
Dim db As DAO.Database
Dim I As Integer
Set db = CurrentDb
IsTableInDatabase = False
db.TableDefs.Refresh
For I = 0 To db.TableDefs.Count - 1
If strTableName = db.TableDefs(I).Name Then
'表存在
IsTableInDatabase = True
Exit For
End If
Next I
Set db = Nothing
End Function
'----判断窗体是否存在------------------
Function IsFormInDatabase(strFormName As String) As Integer
Dim dbCurrent As DAO.Database
Dim strname As String
On Error GoTo Exit_IsFormInDatabase
IsFormInDatabase = False
Set dbCurrent = CurrentDb
strname = dbCurrent.Containers("Forms").Documents(strFormName).Name
IsFormInDatabase = True
Exit_IsFormInDatabase:
End Function
'----判断宏是否存在------------------
Function IsMacroinDatabase(strMacroName) As Integer
Dim dbCurrent As DAO.Database
Dim strname As String
On Error GoTo Exit_IsMacro
IsMacroinDatabase = False
Set dbCurrent = CurrentDb
strname = dbCurrent.Containers("Scripts").Documents(strMacroName).Name
IsMacroinDatabase = True
Exit_IsMacro:
End Function
----判断查询是否存在------------------
Function IsQueryInDatabase(strQueryName As String) As Integer
Dim db As DAO.Database
Dim I As Integer
Set db = CurrentDb
IsQueryInDatabase = False
db.QueryDefs.Refresh
For I = 0 To db.QueryDefs.Count - 1
If strQueryName = db.QueryDefs(I).Name Then
'查询存在
IsQueryInDatabase = True
Exit For
End If
Next I
Set db = Nothing
End Function
'----判断表是否存在------------------
Function IsTableInDatabase(strTableName As String) As Integer
Dim db As DAO.Database
Dim I As Integer
Set db = CurrentDb
IsTableInDatabase = False
db.TableDefs.Refresh
For I = 0 To db.TableDefs.Count - 1
If strTableName = db.TableDefs(I).Name Then
'表存在
IsTableInDatabase = True
Exit For
End If
Next I
Set db = Nothing
End Function
'----判断窗体是否存在------------------
Function IsFormInDatabase(strFormName As String) As Integer
Dim dbCurrent As DAO.Database
Dim strname As String
On Error GoTo Exit_IsFormInDatabase
IsFormInDatabase = False
Set dbCurrent = CurrentDb
strname = dbCurrent.Containers("Forms").Documents(strFormName).Name
IsFormInDatabase = True
Exit_IsFormInDatabase:
End Function
'----判断宏是否存在------------------
Function IsMacroinDatabase(strMacroName) As Integer
Dim dbCurrent As DAO.Database
Dim strname As String
On Error GoTo Exit_IsMacro
IsMacroinDatabase = False
Set dbCurrent = CurrentDb
strname = dbCurrent.Containers("Scripts").Documents(strMacroName).Name
IsMacroinDatabase = True
Exit_IsMacro:
End Function
(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
相关内容
最新内容
推荐内容