Code
' Forms
For i = 0 To CurrentProject.AllForms.Count - 1
fName = CurrentProject.AllForms(i).Name
bOpen = CurrentProject.AllForms(i).IsLoaded
If Not bOpen Then
DoCmd.OpenForm fName, acNormal
End If
If Forms(fName).Module.Find(sFind, StartLine, StartColumn, EndLine, EndColumn) Then
Debug.Print "Form " & fName
End If
For j = 0 To Forms(fName).Controls.Count - 1
cName = Forms(fName).Controls.Item(j).Name
If InStr(1, cName, sFind, vbTextCompare) > 0 Then
Debug.Print "Form " & fName & " Control: " & cName
End If
Next j
If Not bOpen Then
DoCmd.Close , fName, acSaveNo
End If
Next
The problem with this code is it opens all the forms which includes subforms then it errors out. I wish there was a way to search all forms and the VBA code without opening the forms.