|
|
Поиск строки по обьектам базы (Вывод в Immediate Window)
* Показать - Скрыть Immediate Window = Ctrl + G
Public Sub ObjectsWStrInRecSrc(sLookForStr$)
Dim dbs As Database, qdf As QueryDef
Dim objMSA As AccessObject
Dim s$, sSQL$, sLookFor$
On Error GoTo ObjectsWStrInRecSrc_Err
Set dbs = CurrentDb
For Each qdf In dbs.QueryDefs
sSQL = qdf.SQL
If InStr(sSQL, sLookForStr) Then Debug.Print "Запрос: " & qdf.Name
Next
For Each objMSA In CurrentProject.AllForms
s = objMSA.Name
DoCmd.OpenForm s, acDesign, , , , acHidden
sSQL = Forms(s).RecordSource
If InStr(sSQL, sLookForStr) Then Debug.Print "Форма: " & qdf.Name
DoCmd.Close acForm, s, acSaveNo
Next
For Each objMSA In CurrentProject.AllReports
s = objMSA.Name
DoCmd.OpenReport s, acViewDesign
sSQL = Forms(s).RecordSource
If InStr(sSQL, sLookForStr) Then Debug.Print "Отчёт: " & qdf.Name
DoCmd.Close acReport, s, acSaveNo
Next
ObjectsWStrInRecSrc_Bye:
Exit Sub
ObjectsWStrInRecSrc_Err:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in Sub: ObjectsWStrInRecSrc in module: mod_CommonApplication", vbCritical, "Error in Application: " & Err.Source
Err.Clear
Resume ObjectsWStrInRecSrc_Bye
End Sub
|
|