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
ChangeDisplayControl.bmp
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE