A family of Microsoft relational database management systems designed for ease of use.
This is very rough code, but it serves to search all modules (standard, class, form, or report) in the current database for any that don't contain the string "Option Explicit" anywhere. That's not to say that a module couldn't contain that string in a comment or in a literal, but it's a start.
'------ start of code ------
Sub ListModulesWithoutOptionExplicit()
' Check all modules to see if they have "Option Explicit" specified.
' List those that don't in the Immediate Window.
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document
Dim mdl As Access.Module
Dim frm As Access.Form
Dim rpt As Access.Report
Dim strModuleName As String
Dim lngSearchCount As Long
Dim lngFoundCount As Long
Dim bFound As Boolean
Dim bOpenedModule As Boolean
Debug.Print "*** Searching standard and class modules for those not containing ""Option Explicit"" ..."
Set db = CurrentDb
Set cnt = db.Containers("Modules")
For Each doc In cnt.Documents
lngSearchCount = lngSearchCount + 1
strModuleName = doc.Name
If CurrentProject.AllModules(strModuleName).IsLoaded = False Then
DoCmd.OpenModule strModuleName
bOpenedModule = True
DoEvents
Else
bOpenedModule = False
End If
Set mdl = Modules(strModuleName)
If mdl.Find("Option Explicit", 0, 0, 0, 0, True) Then
' Found "Option Explicit", so do nothing
Else
Debug.Print strModuleName
lngFoundCount = lngFoundCount + 1
End If
If bOpenedModule = True Then
DoCmd.Close acModule, strModuleName, acSaveNo
End If
Set mdl = Nothing
Next doc
Debug.Print "*** Searching form modules ..."
For Each doc In db.Containers("Forms").Documents
If CurrentProject.AllForms(doc.Name).IsLoaded = False Then
DoCmd.OpenForm doc.Name, acDesign, WindowMode:=acHidden
bOpenedModule = True
Else
bOpenedModule = False
End If
DoEvents
strModuleName = doc.Name
Set frm = Forms(strModuleName)
With frm
If frm.HasModule Then
lngSearchCount = lngSearchCount + 1
If frm.Module.Find("Option Explicit", 0, 0, 0, 0, True) Then
' Found "Option Explicit", so do nothing
Else
Debug.Print strModuleName
lngFoundCount = lngFoundCount + 1
End If
End If
If bOpenedModule Then
DoCmd.Close acForm, .Name, acSaveNo
End If
End With
Set frm = Nothing
Next doc
Debug.Print "*** Searching report modules ..."
For Each doc In db.Containers("Reports").Documents
If CurrentProject.AllReports(doc.Name).IsLoaded = False Then
DoCmd.OpenReport doc.Name, acDesign, WindowMode:=acHidden
bOpenedModule = True
Else
bOpenedModule = False
End If
DoEvents
strModuleName = doc.Name
Set rpt = Reports(strModuleName)
With rpt
If rpt.HasModule Then
lngSearchCount = lngSearchCount + 1
If rpt.Module.Find("Option Explicit", 0, 0, 0, 0, True) Then
' Found "Option Explicit", so do nothing
Else
Debug.Print strModuleName
lngFoundCount = lngFoundCount + 1
End If
End If
If bOpenedModule Then
DoCmd.Close acReport, .Name, acSaveNo
End If
End With
Set rpt = Nothing
Next doc
Exit_SearchModules:
Set cnt = Nothing
Set db = Nothing
Debug.Print "*** Searched " & lngSearchCount & _
" modules, found " & lngFoundCount & " occurrences."
Exit Sub
Err_Handler:
Debug.Print "* ERROR processing module '" & strModuleName & "' : " & Err.Number & ", " & Err.Description
Resume Next
' MsgBox Err.Description, vbExclamation, "Error " & Err.Number
' If MsgBox("Continue?", vbYesNo, "Continue?") = vbYes Then
' Resume Next
' End If
Resume Exit_SearchModules
End Sub
'------ end of code ------