R
rmanchu
the following code does NOT iterate over all the textbox controls on
the form.
is it because i'm modifying the control within the loop? what's the
solution?
public inttmp as integer
public strtmp as string
public ctltmp as control
Public Sub doFormDesignFormat()
Const frmName = "RecievedDocument"
Const frmPrefix = "RD_"
Dim ctl As Access.Control
DoCmd.OpenForm frmName, acDesign
For Each ctlTmp In Forms(frmName).Controls
If ctlTmp.ControlType = Access.acTextBox _
Or ctlTmp.ControlType = Access.acComboBox _
Or ctlTmp.ControlType = Access.acCheckBox Then
strTmp = ctlTmp.ControlSource
intTmp = InStr(1, strTmp, "_")
If intTmp > 0 Then strTmp = Mid(strTmp, intTmp + 1)
strTmp = frmPrefix & strTmp
ctlTmp.Name = strTmp
ctlTmp.ControlSource = strTmp
Debug.Print "CN:" & ctlTmp.Name & " ,CS:" &
ctlTmp.ControlSource
If ctlTmp.Controls.Count > 0 Then
ctlTmp.Controls(0).Name = strTmp & "_Label"
Debug.Print " CLN:" & ctlTmp.Controls(0).Name
End If
ElseIf ctlTmp.ControlType = Access.acOptionGroup Then
ctlTmp.TabStop = False
intTmp = 1
strTmp = ctlTmp.Name
ctlTmp.Controls(0).Name = strTmp & "_Label"
If ctlTmp.Name = "ogFilterType" Then
ctlTmp.Controls(0).Caption = "Record &Status:"
End If
If ctlTmp.Name = "ogFilterBy" Then
ctlTmp.Controls(0).Caption = "Filter &By:"
End If
Debug.Print "OG:" & ctlTmp.Name
For lngTmp = 1 To ctlTmp.Controls.Count - 1
With ctlTmp.Controls(lngTmp)
If .ControlType = Access.acOptionButton Then
.Name = strTmp & "_Option" & intTmp
.Controls(0).Name = .Name & "_Label"
intTmp = intTmp + 1
Debug.Print " OBN:" & .Name & ", OBLN:" &
..Controls(0).Name
End If
End With
Next lngTmp
End If
Next ctlTmp
DoCmd.Close acForm, frmName, acSaveYes
End Sub
the form.
is it because i'm modifying the control within the loop? what's the
solution?
public inttmp as integer
public strtmp as string
public ctltmp as control
Public Sub doFormDesignFormat()
Const frmName = "RecievedDocument"
Const frmPrefix = "RD_"
Dim ctl As Access.Control
DoCmd.OpenForm frmName, acDesign
For Each ctlTmp In Forms(frmName).Controls
If ctlTmp.ControlType = Access.acTextBox _
Or ctlTmp.ControlType = Access.acComboBox _
Or ctlTmp.ControlType = Access.acCheckBox Then
strTmp = ctlTmp.ControlSource
intTmp = InStr(1, strTmp, "_")
If intTmp > 0 Then strTmp = Mid(strTmp, intTmp + 1)
strTmp = frmPrefix & strTmp
ctlTmp.Name = strTmp
ctlTmp.ControlSource = strTmp
Debug.Print "CN:" & ctlTmp.Name & " ,CS:" &
ctlTmp.ControlSource
If ctlTmp.Controls.Count > 0 Then
ctlTmp.Controls(0).Name = strTmp & "_Label"
Debug.Print " CLN:" & ctlTmp.Controls(0).Name
End If
ElseIf ctlTmp.ControlType = Access.acOptionGroup Then
ctlTmp.TabStop = False
intTmp = 1
strTmp = ctlTmp.Name
ctlTmp.Controls(0).Name = strTmp & "_Label"
If ctlTmp.Name = "ogFilterType" Then
ctlTmp.Controls(0).Caption = "Record &Status:"
End If
If ctlTmp.Name = "ogFilterBy" Then
ctlTmp.Controls(0).Caption = "Filter &By:"
End If
Debug.Print "OG:" & ctlTmp.Name
For lngTmp = 1 To ctlTmp.Controls.Count - 1
With ctlTmp.Controls(lngTmp)
If .ControlType = Access.acOptionButton Then
.Name = strTmp & "_Option" & intTmp
.Controls(0).Name = .Name & "_Label"
intTmp = intTmp + 1
Debug.Print " OBN:" & .Name & ", OBLN:" &
..Controls(0).Name
End If
End With
Next lngTmp
End If
Next ctlTmp
DoCmd.Close acForm, frmName, acSaveYes
End Sub