
Creating a combo box Programmatically on a table
You don't need display control at all. Try this instead:
Public Sub CreateComboBoxcontrol(frmname As String, ctlname As String)
Dim combo As ComboBox
DoCmd.OpenForm frmname, acDesign, , , , acHidden
Set combo = CreateControl(frmname, acComboBox, acDetail, , , 567, 567, 567, 567)
With combo
.Name = ctlname
.RowSourceType = "Value list"
.RowSource = "1;'employee';2;'fun';3;'whynot'"
.ControlSource = "Your field name here"
End With
DoCmd.RunCommand acCmdSave
DoCmd.Close acForm, "frmnav"
End Sub
you'll have to come up with the proper dimensions for the combo box (that's all
of those 567's up there).
Quote:
> I'm having no luck trying to create a combo box programmatically on a
> back-end table.
> the property "DisplayControl" appears to be available ONLY in table Design
> view.
> The combo box I'd like to create contains two fields (the first being the
> value the control is bound to, and the second, of course, is what's shown to
> the user) :
> 1;"Employee";2;"Support Staff";3;"Sub Contract"
> I'd like to do this so that when I update the client's existing version, I
> don't have to do it manually. -That presents another step that can be
> easily forgotten!
> Any ideas would be appreaciated!!!
--
-----------------------------------
Matthew Miller
Ready Net Go, Inc.