1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
'============= FNC001 dvlOpenCloseTablesPrompt =========================
' functions: =
' (01) open and close tables at maximum =
'=======================================================================
' method description:
' This function opens and closes tables at maximum.
' created 29-OCT-2007
' modified 29-OCT-2007
' uses:
' MsgBox()
'
' ADOX::(),CurrentProject::(),DoCmd::()
' inputs:
' none
' outputs:
' dvlOpenCloseTablesPrompt: returned function value
' locals:
' i: counter
' iTables: maximum tables index
' j: counter
'
' strTable: table name
' cat: ADOX.Catalog
' xTab: Access Object for table
' notes:
'
'=======================================================================
Function dvlOpenCloseTablesPrompt() As Long
'
' global variables:
'
'
' local variables:
'
Dim i As Long, iTables As Long, j As Long
'
Dim strTable As String
'
Dim cat As ADOX.Catalog
'
Dim xTab As AccessObject
'
' function body:
'
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection
iTables = cat.Tables.Count - 1
'
' STEP 1: open tables:
'
On Error GoTo ErrorOpening
'
j = 0
For i = 0 To iTables
'
' open users created tables only, not view, neither system tables:
'
If (cat.Tables(i).Type = "TABLE") Then
strTable = cat.Tables(i).Name
DoCmd.OpenTable strTable, acViewNormal, acReadOnly
j = j + 1
End If
Next
'
ErrorOpening:
'
Set cat = Nothing
'
MsgBox "Number of Maximum Tables Opened: " & j & "."
'
' STEP 2: close opened tables:
'
On Error GoTo ErrorStatus
'
i = 0
'
For Each xTab In Application.CurrentData.AllTables
If (xTab.IsLoaded) Then
DoCmd.Close acDefault, xTab.Name
i = i + 1
End If
Next
'
' set function value:
'
Set xTab = Nothing
dvlOpenCloseTablesPrompt = j
Exit Function
'
ErrorStatus:
'
dvlOpenCloseTablesPrompt = 0
'
' exit the function:
'
End Function |
Partager