0
votes

I have a Access Form with an ComboBox control whose attached recorset contains a Null value as the index of one of the rows, and set to display the second column of the recordset.

When I open the list, I can see all the rows, including the one with Null as index, and I can select it, but as soon as the AfterUpdate event ends, the displayed text is erased.

I would like to display the second column for Null, but I cannot managed to achieve that. I suppose this is due to Null being equal to nothing (not even itself), but is there a workaround?

Example of database:

 Id      Description
+------+-------------+
|      | Default     |
|1     | Choice 1    |
|2     | Choice 2    |
.
.
.

If I select 'Default' in the ComboBox, the value is correctly set to Null, but the displayed text is empty. If I select 'Choice 1' (or 'Choice 2') The value is correctly set to 1 (resp. 2) and the displayed value in the ComboBox is 'Choice 1' (resp. 'Choice 2').

Edit: For compatibility reasons, the solution must work with Access 2007

1

1 Answers

0
votes

You can use MyCombo.ListIndex = 0 to pick the first value in a combobox. This won't set the value from memory but should display correctly.