|
|
Проверка всех таблиц на наличие полей с подстановкой и возможностью удаления этого свойства (опционально)
Public Sub PrintAllLookupFields(Optional blnFixLookUpProperty As Boolean)
Dim tdf As DAO.TableDef, objField As DAO.Field
Dim objPrp As Property
Dim blnHasLookUpProperty As Boolean
Dim sVal$, sTableName$, sFieldName$, sPrpName$, iTablesCount%, iLookUpFieldsCount%
Const iLineLength% = 100
For Each tdf In CurrentDb.TableDefs
If (tdf.Attributes And dbSystemObject) = False Then
sTableName = tdf.Name
iTablesCount = iTablesCount + 1
For Each objField In tdf.Fields
blnHasLookUpProperty = CheckProperty(objField, "DisplayControl")
If blnHasLookUpProperty = True Then
sFieldName = objField.Name
Set objPrp = objField.Properties("DisplayControl")
If objPrp.Value = acComboBox Or objPrp.Value = acListBox Then
iLookUpFieldsCount = iLookUpFieldsCount + 1
If blnFixLookUpProperty = True Then
If Not objField.Type = 1 Then
objPrp.Value = acTextBox
sVal = "- исправлено на 109 (acTextBox)."
Else
objPrp.Value = acCheckBox
sVal = "- исправлено на 106 (acCheckBox)."
End If
sVal = vbTab & "Табл: [" & sTableName & "]" & _
" - Поле: [" & sFieldName & "] " & _
"Свойство: [DisplayControl] " & sVal
Else
sVal = "Таблица: [" & sTableName & "]" & _
" - Поле с подстановкой : [" & sFieldName & "]"
End If
Debug.Print sVal
End If
End If
Next objField
End If
Next tdf
If iLookUpFieldsCount > 0 Then
Debug.Print String(iLineLength, "-")
If blnFixLookUpProperty = False Then
sVal = "Обработано: " & iTablesCount & " таблиц" & _
" - Найдено полей с подстановкой : " & iLookUpFieldsCount
Else
sVal = "Обработано: " & iTablesCount & " таблиц" & _
" - Исправлено полей с подстановкой : " & iLookUpFieldsCount
End If
Else
sVal = "Обработано: " & iTablesCount & " таблиц и полей с подстановкой не найдено!"
End If
Debug.Print sVal
Debug.Print String(iLineLength, "=")
End Sub
Private Function CheckProperty(obj As Object, sPrpName$) As Boolean
Dim sVal$: On Error GoTo CheckPropertyPresent_Err
sVal = obj.Properties(sPrpName): CheckProperty = True
Exit Function
CheckPropertyPresent_Err:
Err.Clear
End Function
|
|