Public Function IsLoadedQry(ByVal strQName As String) As Boolean
IsLoadedQry = False
If SysCmd(acSysCmdGetObjectState, acQuery, strQName) = acObjStateOpen Then
IsLoadedQry = True
End If
End Function
''''
Public Function IsLoadedTbl(ByVal strQName As String) As Boolean
IsLoadedTbl = False
If SysCmd(acSysCmdGetObjectState, acTable, strQName) = acObjStateOpen Then
IsLoadedTbl = True
End If
End Function
''''
Public Sub closetblqvr()
Dim tdf As TableDef
Dim qdf As QueryDef
For Each tdf In CurrentDb.TableDefs
If IsLoadedTbl(tdf.Name) Then DoCmd.Close acTable, tdf.Name
Next tdf
For Each qdf In CurrentDb.QueryDefs
If IsLoadedQry(qdf.Name) Then DoCmd.Close acQuery, qdf.Name
Next qdf
End Sub
|