I'm not sure this is of any help but here's a function that returns the
average of certain controls on a form based upon the name of the control.
You might be able to use this to write a function that changes the property
of many textboxes on a form:
Public Function AveAllControlsOnFormWithFieldName(strFieldName As String) As
Double
' this function returns the Average of all controls on the form
' that have strFieldName as part of their name
Dim dblControlSum As Double, strControlName As String,
lngNumOfNumericControls As Long
Dim NumOfControls As Long, I As Long, lngControlCount As Long
NumOfControls = Me.Controls.Count ' number of controls on form
dblControlSum = 0 ' stores the sum
lngNumOfNumericControls = 0 ' keeps track of how many numeric controls
' now loop through every control on form
For I = 0 To (NumOfControls - 1) ' controls start at 0
If IsNumeric(Me(I)) Then ' check to see if it's a number
strControlName = Me(I).Name ' store the name of the control
' now see if the second string is contained in the first
If InStr(1, strControlName, strFieldName, vbTextCompare) > 0
Then
dblControlSum = dblControlSum + Me(I).Value ' if substring
is found then
lngNumOfNumericControls = lngNumOfNumericControls + 1
End If
End If
Next I
AveAllControlsOnFormWithFieldName = dblControlSum /
lngNumOfNumericControls
End Function