Sub CreateField(strTable As String, strField As String, strsql As String) Dim MyDB As Database Dim MyTbl As TableDef Dim MyField As DAO.Field Set MyDB = CurrentDb Set MyTbl = MyDB.TableDefs(strTable) Set MyField = MyTbl.CreateField(strField, dbLong) MyTbl.Fields.Append MyField MyField.Properties("DisplayControl") = 111 'The "111" value converts to a combo box MyField.Properties("RowSourceType") = "Table/Query" 'The properties below don't exist until the Display Control is changed to a combo box. But the added properties "RowSource", "ComolumCount" and '"ColumnWidths" do not magically appear after I've changed DisplayControl to "111". MyField.Properties("RowSource") = strsql MyField.Properties("ColumnCount") = 2 MyField.Properties("ColumnWidths") = "0;1440" End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.