|
|
Изменение свойств всех форм приложения
Простенький перебор:
Private Sub AllFormsInApp()
Dim dbs As Database, ctr As Container, doc As Document
On Error GoTo AllFormsInApp_Err
Set dbs = CurrentDb
Set ctr = dbs.Containers!Forms
For Each doc In ctr.Documents
Debug.Print "Processing the form:" & doc.Name
Next doc
AllFormsInApp_Bye:
Set ctr = Nothing
Set dbs = Nothing
Exit Sub
AllFormsInApp_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in procedure AllFormsInApp", vbCritical, "Error!"
Resume AllFormsInApp_Bye
End Sub
Вариации по теме:
Private Sub ChangeFormsPrp()
Dim dbs As Database, ctr As Container, doc As Document
Dim objForm As Form
On Error GoTo ChangeFormsPrp_Err
Set dbs = CurrentDb
Set ctr = dbs.Containers!Forms
For Each doc In ctr.Documents
DoCmd.OpenForm doc.name, acDesign, "", "", , acHidden
Set objForm = Forms(doc.name)
Debug.Print "Обрабатываю форму - " & doc.name
objForm.AutoCenter = True
DoCmd.Close acForm, doc.name, acSaveYes
Next doc
ChangeFormsPrp_Bye:
Set objForm = Nothing
Set ctr = Nothing
Set dbs = Nothing
Exit Sub
ChangeFormsPrp_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in procedure ChangeFormsPrp", vbCritical, "Error!"
Resume ChangeFormsPrp_Bye
End Sub
Изменение свойств (Properties) указанной в аргументе формы
Public Sub Change_Form_Properties(sFormName As String)
Dim objForm As Form, prp As Property
On Error GoTo Change_Form_Properties_Err
DoCmd.OpenForm sFormName, acDesign, "", "", , acHidden
Set objForm = Forms(sFormName)
With objForm
.AllowDatasheetView = False
.AllowPivotTableView = False
.AllowPivotChartView = False
.AllowLayoutView = False
.AutoCenter = True
.RecordSelectors = False
.NavigationButtons = False
.ScrollBars = 0
.ControlBox = True
.CloseButton = True
.MinMaxButtons = 0
End With
DoCmd.Close acForm, sFormName, acSaveYes
DoCmd.OpenForm sFormName
Change_Form_Properties_Bye:
On Error Resume Next
Set prp = Nothing
Set objForm = Nothing
Exit Sub
Change_Form_Properties_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in procedure Change_Form_Properties", vbCritical, "Error!"
Resume Change_Form_Properties_Bye
End Sub
|
|