In my code, I read through fields on a form and then based on values in a related query, I update the properties of the control.
This code works when I assign a value to the "width" and format properties. But I get an error ("to set this property, open the form in design view") when I attempt to change the Control type to a combo box. I'm also then attempting to set the Row Source Type and Row Source.
Any suggestions?
This code works when I assign a value to the "width" and format properties. But I get an error ("to set this property, open the form in design view") when I attempt to change the Control type to a combo box. I'm also then attempting to set the Row Source Type and Row Source.
Any suggestions?
Code:
Dim txt As Access.TextBox
With rs
If Not .EOF Then
Do Until .EOF
Set txt = Me.Controls.Item("txt" & cnt)
txt.Width = !FieldWidth * 1440
If sFieldType = "D" Then ' this is a date field
txt.Format = "Short Date"
Else
End If
If sFieldType = "C" Then ' this is a choice/ combo box field
txt.ControlType = acComboBox
' txt.RowSource = "tblChoices"
Else
End If
etc.