Ahmed Yousry
Ahmed Yousry

Reputation: 25

Setting the RowSource property of a field which has a ComboBox Display Control in Access VBA

I'm creating a dynamic temporary table using VBA. The table stores some values in order to be processed and confirmed by the user before being stored to the database.

I managed to display one of the table's fields as a ComboBox using the code below

Set prp = fld.CreateProperty("DisplayControl", vbLong, acComboBox)
fld.Properties.Append prp

However I don't know how to populate the ComboBox displayed field.
I tried creating another property for the RowSourceType and the RowSource but I don't know how to fill the parameters.

Set prp = fld.CreateProperty("RowSourceType", ?, ?)

Upvotes: 1

Views: 1722

Answers (1)

Ahmed Yousry
Ahmed Yousry

Reputation: 25

Ok, I found the answer shortly after I posted the question. I'll leave the answer for anyone who might need it.

Set prp = fld.CreateProperty("RowSourceType", dbText, "Table/Query")
fld.Properties.Append prp
Set prp = fld.CreateProperty("RowSource", dbText, "SELECT * FROM TBL;")
fld.Properties.Append prp

You can also add the two properties below to set the column count and the column width.

Set prp = fld.CreateProperty("ColumnCount", dbInteger, 2)
fld.Properties.Append prp
Set prp = fld.CreateProperty("ColumnWidths", dbText, "0;1440")
fld.Properties.Append prp

Upvotes: 1

Related Questions