I don't have the time now to write up a proper article on this but I just had to develop this code so I thought I'd share it.
It's to handle turning off of
The code below displays all forms and, within each, any controls that have
NB. There is also an application level option that allows this to be disabled, but not every developer has full control of all their users' application options so this can prove useful anyway.
NB. The name is not a typo in this case.
It's to handle turning off of
.AllowAutoCorre ct. This is often the cause of users having difficulties trying to enter data and noticing later (or not sometimes even) that what they thought they'd typed isn't what was saved.The code below displays all forms and, within each, any controls that have
.AllowAutoCorre ct set to True. An optional parameter, blnFix, allows the caller to request that all occurrences are fixed to disallow this feature.NB. There is also an application level option that allows this to be disabled, but not every developer has full control of all their users' application options so this can prove useful anyway.
Code:
'AutoCorrupt() Prints off every form control that has AutoCorrect set to True.
Public Sub AutoCorrupt(Optional ByVal blnFix As Boolean = False)
Dim blnAC As Boolean
Dim lngSave As Long
Dim ctlVar As Control
Dim aoVar As AccessObject
For Each aoVar In CurrentProject.AllForms
Call DoCmd.OpenForm(FormName:=aoVar.NAME _
, View:=acDesign _
, WindowMode:=acHidden)
With Forms(aoVar.NAME)
Debug.Print "@"; aoVar.NAME;
lngSave = acSaveNo
For Each ctlVar In .Controls
On Error Resume Next
blnAC = ctlVar.AllowAutoCorrect
On Error GoTo 0
If blnAC Then
Debug.Print "~"; ctlVar.NAME;
If blnFix Then
ctlVar.AllowAutoCorrect = False
lngSave = acSaveYes
End If
blnAC = False
End If
Next ctlVar
End With
Call DoCmd.CLOSE(ObjectType:=acForm _
, ObjectName:=aoVar.NAME _
, Save:=lngSave)
Next aoVar
End Sub
Comment