0
votes

I have a combo box in my form which I filled from another table role.
role has two columns : Id and Role
Given my table in Row Source and Bound Column value as 2 and column widths as 0cm;2cm

I can see my Role in combo box which is fine. What I need is

  1. On Submit, I want to read the Id value in VBA for the Role selected. How to achieve this -- Resolved it by setting Bound Column value as 1
  2. How to set Default Value as one of the Role -- Help to make this happen

I have to set similar case for my ListBox in same form

1
First point is solved now. How to set one of my Role value as Defaulted one when Form loadsDavey_31
Combobox has DefaultValue property. Put whatever ID you want in there.June7
@June7 Thank you. sorry SO not allowing your comment to tick as answer..badDavey_31

1 Answers

3
votes

Since you have a multi-column combo box, both questions relate to the same combobox property : column

MyComboBox.Column(Index, Row)

Row is optional.

Use 0 to refer to the first column, 1 to refer to the second column, and so on. Use 0 to refer to the first row, 1 to refer to the second row, and so on.

Question 1: Suppose you bound your id to the second column. In the submit code, you can retrieve your id like this: myid = MyComboBox.Column(1)

Question 2: Suppose you want to assign role id = 3 and your id is bound to column 2. In the Load event of your form, do this : MyComboBox.Column(1) = 3