Create a form called frmUtils and put a single button on it. In the
"On Click" event put the following:
=HidDBObjects()
In a code module put the following code:
Public Function HidDBObjects()
On Error GoTo Err_HidDBObjects
Dim vHid As Boolean
Dim vAnswer As String
vAnswer = MsgBox("Select ""Yes"" to Hid All DB Objects; Select ""No""
to Unhid All DB Objects!", vbQuestion + vbYesNoCancel, "Hid All DB
Objects")
If vAnswer = vbYes Then
vHid = True
ElseIf vAnswer = vbNo Then
vHid = False
ElseIf vAnswer = vbCancel Then
Exit Function
End If
Application.Echo False
HourGlass_On
If IsLoaded("frmUtils") = True Then
DoCmd.Close acForm, "frmUtils", acSaveYes
End If
HidTables vHid
HidFormsReportsMacros vHid
Application.Echo True
HourGlass_Off
Exit_HidDBObjects:
Exit Function
Err_HidDBObjects:
MsgBox Err.Description
Resume Exit_HidDBObjects
End Function
Public Function HidFormsReportsMacros(vbln As Boolean)
'Hids/Unhids all the forms, reports and macros in the database.
Dim obj As AccessObject
Dim dbs As Object
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
Application.SetHiddenAttribute acForm, obj.Name, vbln
Next obj
For Each obj In dbs.AllReports
Application.SetHiddenAttribute acReport, obj.Name, vbln
Next obj
For Each obj In dbs.AllModules
Application.SetHiddenAttribute acModule, obj.Name, vbln
Next obj
For Each obj In dbs.AllMacros
Application.SetHiddenAttribute acMacro, obj.Name, vbln
Next obj
Set dbs = Application.CurrentData
For Each obj In dbs.AllQueries
Application.SetHiddenAttribute acQuery, obj.Name, vbln
Next obj
End Function
Public Function HidTables(vbln As Boolean)
Dim db As Database
Dim T As TableDef
Dim TName As String
Dim I As Integer
Dim vCnt As Integer
Set db = CurrentDb()
'Code below Hids or UnHids all non-system tables in a database.
For I = 0 To db.TableDefs.Count - 1
Set T = db.TableDefs(I)
TName = T.Name
If Not TName Like "msys*" Then
Application.SetHiddenAttribute acTable, TName, vbln
vCnt = vCnt + 1
End If
Next I
End Function