0
votes

I have a combo box in Access named StateID. It's rowsource contains two columns one is ID which is in Column 0 and another is description which is Column 1.

I want to populate the value of the ID column by doing something like:

StateID.Column(0) = rs("ID")

I made sure that the combobox is name StateID. The rs("ID") is also returning a value but my code breaks on the line above and I get

Object Required

error. I alos tried Me.StateID.Column(0) and StateID.Column(0).value but I still get the same error

3

3 Answers

0
votes

You cannot do "something like" that because the "Column" property is Read-Only, per Microsoft Access documentation; seems like this is your problem.

0
votes

I dont' know why you don't assign the record source in design mode. Any way, in the Form Load event you can do this

    StateID.RowSource = "SELECT codage,nomage FROM TheTable"
0
votes

Well I just tried various things and doing it this way works:

  With StateID
     .ColumnCount = 2
     .Value = rs("ID")
 End With