combobox not always displaying chosen content

W

WHOLEministries

I have a subform with two comboboxes. One is dependent on the other
and the control sources for each are in the same table.
When scrolling through the records on the main form, the first combobox
always displays the option that was selected previously. However the
second combobox does not. Sometimes it does, sometimes it does not.
For testing purposes, I have added a text box that displays the value
from the underlying table that was entered via the second combobox, and
the data is always there. However, as I said, the second combobox does
not always display the info.
Is there a good reason or explanation for this? I would prefer to be
able to get rid of the text box and have the data properly displayed in
the comboboxes.

TIA
 
M

Marshall Barton

I have a subform with two comboboxes. One is dependent on the other
and the control sources for each are in the same table.
When scrolling through the records on the main form, the first combobox
always displays the option that was selected previously. However the
second combobox does not. Sometimes it does, sometimes it does not.
For testing purposes, I have added a text box that displays the value
from the underlying table that was entered via the second combobox, and
the data is always there. However, as I said, the second combobox does
not always display the info.
Is there a good reason or explanation for this? I would prefer to be
able to get rid of the text box and have the data properly displayed in
the comboboxes.


This is expected behavior in a form using either Continuous
or Datasheet view. Using a text box is the standard way to
display the second combo box's data.

For a continuous form, if you place the text box exactly on
top of the combo box's text portion and set its Locked = Yes
and Enabled to No, you should not be able to tell the
difference.

If that's not your situation, I have no explanation for the
described behavior.
 
P

papa jonah

That does seem to work in one case that I have. The other case I have
not had to use the text box. What I find interesting is if I change
the rowsource, to read like
select [subreasonid],[subreason] from [zlookup: subreason]
it works fine. However, at times, which I can not nail down, the
rowsource adds a "where ..." to the sql. When that happens, the
display quits working in the second combobox EXCEPT where the value
equals the number in the "where" part of the sql.
I can't figure out why that occurs. It is only on occassion. If I
delete the where part of the sql, close the form, and reopen it. It
seems to work fine - for awhile.
 
M

Marshall Barton

papa said:
That does seem to work in one case that I have. The other case I have
not had to use the text box. What I find interesting is if I change
the rowsource, to read like
select [subreasonid],[subreason] from [zlookup: subreason]
it works fine. However, at times, which I can not nail down, the
rowsource adds a "where ..." to the sql. When that happens, the
display quits working in the second combobox EXCEPT where the value
equals the number in the "where" part of the sql.
I can't figure out why that occurs. It is only on occassion. If I
delete the where part of the sql, close the form, and reopen it. It
seems to work fine - for awhile.


Either the query already had the where clause or, more
likely, you have code (in the first combo's AfterUpdate
event?) that adds it. After all, it's that where clause
that make the second combo box dependent on the first one
and creates the situation under discussion.

Note that this issue is highly dependent on the second combo
box's BoundColumn and ColumnWidths properties. In your
above query, you will not have the issue at all if the
BoundColumn (e.g. 1) is the same as the first column with a
non-zero column width (e.g. .5,1.5). In this arrangement,
the combo box displays its value.

The more common arrangement is to have BoundColumn set to 1,
but ColumnWidths= 0,1. Here, the combo box is displaying
something from the row source table instead of its value
(stored in the form's record source table), so, unless the
where clause matches the first combo box's value, the item
in the row source table will not be included in the list and
not available to be displayed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top