Unbound combobox doesn't display selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have an unbound form that's embedded as a subform in another form.
The subform's recordset is set dynamically when a record is selected
in the main form. The subform is set to Continuous. The header has a
set of text boxes and comboboxes used to edit the data in whichever
record is selected or to enter new records. I populate the rowsources
in the header comboboxes with stored procs with two columns, a key
column and a description. I have the following settings in the
combobox:
BoundColumn: 1 (key field)
ColumnWidths: 1";1"
ColumnCount: 2
ControlSource: I never put anything here; always blank.

When the recordset of the subform has pre-existing records, everything
works as expected. However, when the subform's
Recordset.Recordcount=0, making a selection in one of the comboboxes
doesn't work as expected. The value in the key column comes through in
the control's value property in code, but the value is not displayed.
When I change the BoundColumn property to "2", the value in column 1
is displayed, but the Value property of the combobox picks up the
value in column 2.

I have found that if I put the following code in the routing that
fills the recordset, it seems to work:

If Me.Recordset.RecordCount = 0 Then
Set .Recordset = Nothing
End If

I consider this a reasonable workaround, but still cannot figure out
why an unbound combobox is affected by a recordset's recordcount. Also
a little peaved that this bug/feature cost me >8 hours of my time.

Any ideas about what is going on here would be helpful.
 
If a form:
a) has no records, and
b) no new records can be added,
then the detail section goes completely blank.

When this happens, Access gets confused. The controls in the Form Header and
Form Footer sections still display, but several bugs surface including blank
display, the ability to select text that is not visible, and Access
insisting that the control does not have focus when it does.

These bugs have been present for at least the last 6 versions of Access (the
last 10 years), so don't hold your breath for MS to fix them. Sorry: no
solution, but we have documented the bugs in this article:
Incorrect display of data
at:
http://members.iinet.net.au/~allenbrowne/bug-06.html
 
Back
Top