Prohibition of the conclusion window
In process of the development of the form very intensive is used window of the task characteristic оъекта. But when development is finished, that appearance this window in worker of the versions of the program undesirable. Intimates on low qualification of the developer. In Access 2000 (and senior), characteristic AllowDesignChanges appeared in the form, which controls the output a window characteristic on screen. It has a type Boolean.
Importances:
- True (-1) - (By default) of the Change characteristic object can be made in all mode of the form.
- False (0) - Change characteristic object can be made in mode of the constructor only. His(its) possible change on вкладке "Other" in most bottom of the list parameter. In russian version it is identified "to Allow change the model" and has importances - "All modes" (True) and "Only mode of the constructor" (False).
Certainly, importance of this parameter possible to install manually. If the forms several, that this do easy. But if their several groups of ten? Immediately appears the offer: insert in separate module global variable blnDesignForm and assign her importance True for time of the development of the program.
Public Const blnDesignForm As Boolean = True
In each form, in sections Form_Load to insert line
Me.AllowDesignChanges = blnDesignForm
After completion of the development to change importance blnDesignForm with True on False.
Regrettably turned out to be that all not so simply. The Attempt is software to change the parameter of the form AllowDesignChanges, gives the mistake 2448 "Impossible assign importance an object". Turned out to be that this characteristic possible to change in mode of the constructor only. So it happened to to go on the other way and write the necessary subroutine.
Public Sub SetChangeDesignDAO()
' Subroutine of the change the parameter of the form AllowDesignChanges permit on conclusion window parameter on screen in all mode True or only in mode of the constructor - False In subroutine are used some ideas YUriya SHermana ' For start the subroutine install on it marker and press F5
Dim MN As String, j As Integer, n As Integer
Dim ContainerName As String
Dim blnChange As Boolean
On Error GoTo SetChangeDesignDAO_Error
ContainerName = "Forms"
' Choice of the mode of the conclusion window свойств
Select Case MsgBox("Allow the conclusion a window parameter on screen in mode of the constructor only?" _
& vbCrLf & "(Нет(No) - in all mode)" _
, vbYesNoCancel Or vbQuestion Or vbDefaultButton1, _
"Installing the mode of the conclusion window parameter on screen")
Case vbYes
' permit on conclusion window parameter on screen in mode of the constructor only
blnChange = False
Case vbNo
' permit on conclusion window parameter on screen in all mode
blnChange = True
Case vbCancel
' cancelling the performing the subroutine
Exit Sub
End Select
' we quantify forms
n = CurrentDb.Containers(ContainerName).Documents.Count - 1
' we prepare status line for conclusion прогрессбара
If n >= 0 Then
' removes in status line word Forms
SysCmd acSysCmdSetStatus, ContainerName
' removes in status line amount forms
SysCmd acSysCmdInitMeter, ContainerName, (n + 1)
else
' output from procedure if forms no
Exit Sub
end if
' forms
For j = 0 To n
MN = CurrentDb.Containers(ContainerName).Documents(j).Name
' we open form in mode of the constructor
DoCmd.OpenForm MN, acDesign, , , , acHidden
Forms(MN).AllowDesignChanges = blnChange
' we close form with conservation
DoCmd.Close acForm, MN, acSaveYes
' we change importance прогрессбара in status line
SysCmd acSysCmdUpdateMeter, (j + 1)
Next
' we clean status line
SysCmd acSysCmdClearStatus
On Error GoTo 0
Exit Sub
SetChangeDesignDAO_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SetChangeDesignDAO"
End Sub
All this well worked, but when I перешел on ADP, subroutine happened to to process. This is because for ADP CurrentDB does not act. Happened to little sit on subroutine. Now her(its) possible use and in MDB and in ADP.
Public Sub SetChangeDesignADO() 'blnChange As Boolean)
Dim FormName As String, j As Integer, n As Integer
Dim ContainerName As String
Dim blnChange As Boolean
On Error GoTo SetChangeDesignADO_Error
ContainerName = "Forms"
Select Case MsgBox("Разрешить вывод окна параметров на экран только в режиме конструктора?" _
& vbCrLf & "(Нет(No) - во всех режимах)" _
, vbYesNoCancel Or vbCritical Or vbDefaultButton1, _
"Установка режима вывода окна параметров на экран")
Case vbYes
blnChange = False
Case vbNo
blnChange = True
Case vbCancel
Exit Sub
End Select
n = CurrentProject.AllForms.Count - 1
If n >= 0 Then
SysCmd acSysCmdSetStatus, ContainerName
SysCmd acSysCmdInitMeter, ContainerName, (n + 1)
else
Exit Sub
end if
For j = 0 To n
FormName = CurrentProject.AllForms(j).Name
DoCmd.OpenForm FormName, acDesign, , , , acHidden
Forms(FormName).AllowDesignChanges = blnChange
DoCmd.Close acForm, FormName, acSaveYes
SysCmd acSysCmdUpdateMeter, (j + 1)
Next
SysCmd acSysCmdClearStatus
On Error GoTo 0
Exit Sub
SetChangeDesignADO_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SetChangeDesignADO"
End Sub
The Note: in Access 97 I not smog to find the analogue a characteristic AllowDesignChanges though at transformation from Access 2000, possibility to open the window a characteristic object in mode of the form is blocked.
Author: Dmitriy Sleepy (aka Joss)
It Is Added: 27.01.2008