组合框依赖于另一个组合框,文本部分为空白 [英] Combo box dependent on another combo box, text part is blank

查看:51
本文介绍了组合框依赖于另一个组合框,文本部分为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个带有几个组合框的表格,连续的表格格式,

记录来源查询项目表格。字段是Category,

子类别和颜色。我正在显示描述,而不是ID',所以我

必须从各种查找表转换ID。


组合框工作除了子类别,这取决于

类别。根据类别,子类别

的下拉框将显示不同的项目。 (例如,当分类为

家具,子类别将显示''梳妆台,

床头柜,书桌......)的下拉列表。没有点击下拉框,

子类别将在其文本区域中显示表格中现有记录的

子类别ID的描述。


Subcategory的下拉列表工作正常。但是,对于第二类记录,文本

部分为空白。换句话说,

有第一类的10条记录,附件。子类别

显示罚款。但是对于第11条记录和随后的

记录,子类别是空白的(文本部分,尽管下降 - 下来工作

正确)。


如果我只是显示子类别ID,而不是转换为描述,那么

工作正常。


我的子类别的SQL语句是:

" SELECT ItemSubcatID,ItemSubcatDesc FROM tlkpItemSubcategory

WHERE(((ItemCategoryID)= [Forms]![frmItems]![cboItemCategory]))

ORDER BY ItemSubcatDesc;"


列数为2,列宽为0,2。绑定列为1.

我认为问题出在这里。当我的列宽=

" 1,1"时,我可以看到我的subcatgegory ID正确显示。


我重新查询子类别在category_afterupdate和

category_change ...但是组合框下拉部分似乎是

工作正常。


如果我只运行'是记录源的查询,它正确显示

子类别。


什么会导致我的组合框的文本部分是空白?


提前感谢您的帮助,

Lori

解决方案

你说基础查询在你运行它的时候工作正常吗?
本身...该查询中的每条记录都有一个子类别ID吗?另外,

您是否有任何具有子类别ID但没有文本的记录

ItemSubcatDesc?当您按文字字段升序排序时,您首先得到空白

字段。对于故障排除,您可以将ORDER BY更改为

ORDER BY ItemSubcatDesc DESC;并且看看你是否得到了更好的结果。


尝试使你的列宽大约为4或5英寸

(相应地延长你的组合框)看看你是否只需拥有一对

的记录,这些记录的当前组合框配置了大量文本

。我知道你可能确切地知道你的数据中有什么?
字段,但你永远不知道会出现什么。


2005年12月16日08:54:15 -0800,lorirobn <螺****** @ yahoo.com>写道:



我有一个带有几个组合框的表单,连续的表单格式,带有
记录源的项目表查询。字段是Category,
Subcategory和Color。我正在显示描述,而不是ID',所以我必须从各种查找表转换ID。

组合框工作正常,除了子类别,这是依赖的在
类别。根据类别,子类别的下拉框将显示不同的项目。 (例如,当Category为
家具时,子类别将显示''Dresser,
Nightstand,Desk ......)的下拉列表。无需点击下拉框,
子类别将在其文本区域中显示表格中现有记录的子类别ID的描述。

子类别的下拉列表工作正常。但是,文本
对于第二类记录,部分为空白。换句话说,
第一类有10条记录,附件。子类别
显示这些记录正常。但是对于第11条记录和随后的记录/>记录,子类别是空白的(文本部分,虽然下拉列表工作正确)。

如果我只是显示子类别ID,而不是转换为描述,那么
有效很好。

我的子类别的SQL语句是:
" SELECT ItemSubcatID,ItemSubcatDesc FROM tlkpItemSubcategory
WHERE(((ItemCategoryID)= [Forms]![frmItems]![cboItemCategory ]))
按ItemSubc排序atDesc;

列数为2,列宽为0,2。绑定列为1.
我认为问题出在这里。当我有列宽=
1,1时,我可以看到我的subcatgegory ID正确显示。

我在category_afterupdate和
category_change上重新查询子类别...但是组合框下拉部分似乎工作正常。

如果我只运行'是记录源的查询,它会显示
子类别正确。

什么会导致我的组合框的文本部分为空?

提前感谢您的帮助,



我想你会发现当你改变

控制的组合框的值时,动态更改你的依赖组合框

的rowsource它。


当您修改rowsource时,您会发现任何不再位于rowsource中的具有

ID'的框将显示为空白。这个

是因为如果

组合框被绑定并且正在显示绑定列,Access可以显示基础数据(即使

那里是不匹配的),如果绑定列以外的任何东西都显示为

,因为绑定列没有匹配,其余的

列是未定义的 ;


解决方案,例如它(并且它不是非常好的)是

确保任何依赖的组合框他们的绑定列等于

你希望在屏幕上显示的信息。


mike


< BLOCKQUOTE>嗨。谢谢你们的回复。


史蒂夫:

我刚检查过,并且:

- 每个记录基础查询有一个子类别ID。

- 所有具有子类别ID的记录在子类别desc中都有文本。

- 我没有先得到空白字段。我得到了第一个

类别的描述,然后是第二类的空白。


Mike:

除非我误解了你,我实际上并没有主动更改

记录源。我描述的情况是在表单最初使用表中的值填充
时发生的。当它用数据填充

表格时,子类别正确地填入第一个

类别,那么当它填写第二个数据时它会留空

类别。我实际上并没有改变任何东西,只是看着

表格正在填充表格中的数据。这有意义吗?


我想知道我是否在这个连续的表格中没有正确引用当前的CategoryID,



再次感谢,

Lori



***通过Developersdex发送 http://www.developersdex.com ***


Hi,

I have a form with several combo boxes, continuous form format, with
record source a query off an Item Table. The fields are Category,
Subcategory, and Color. I am displaying descriptions, not ID''s, so I
have to convert the ID''s from various lookup tables.

The combo boxes work fine except for subcategory, which is dependent on
category. Depending on category, the drop-down box for subcategory
will display different items. (for example, when Category is
Furniture, Subcategory will display drop-down list of ''Dresser,
Nightstand, Desk...". Without clicking on the drop-down box,
subcategory will display in its text area the Description of the
subcategory ID of the existing record on the table.

The drop-down list for Subcategory works fine. However, the text
portion is blank for records on the 2nd category. In other words,
there are 10 records for the first category, Accessories. Subcategory
displays fine for these. But for the 11th record and subsequent
records, subcategory is blank (text portion, although drop-down works
correctly).

If I just display subcategory ID, and not convert to description, it
works fine.

My SQL statement for subcategory is:
"SELECT ItemSubcatID, ItemSubcatDesc FROM tlkpItemSubcategory
WHERE (((ItemCategoryID)=[Forms]![frmItems]![cboItemCategory]))
ORDER BY ItemSubcatDesc;"

Column count is 2, column width is 0, 2. Bound column is 1.
I think the problem lies around here. When I have column width =
"1,1", I can see that my subcatgegory ID is displayed correctly.

I do a requery of subcategory on category_afterupdate and
category_change... but the combo boxes drop-down part seem to be
working fine.

If I run just the query that''s the record source, it displays
subcategories correctly.

What would cause the text portion of my combo box to be blank?

Thanks in advance for any help,
Lori

解决方案

You said the underlying query works fine when you run it by
itself...does each record in that query have a subcategory ID? Also, do
you have any records that have a subcategory ID but no text in
ItemSubcatDesc? When you ORDER BY a text field ascending, you get blank
fields first. For troubleshooting, you could change your ORDER BY to
ORDER BY ItemSubcatDesc DESC; and see if you get a better result.

Try making your column width something like four or five inches
(lengthen your combobox accordingly) to see if you simply have a couple
of records that have an awful lot of text for your current combobox
configuration. I realize you probably know exactly what''s in your data
fields, but you never know what might pop up.


On 16 Dec 2005 08:54:15 -0800, "lorirobn" <lo******@yahoo.com> wrote:

Hi,

I have a form with several combo boxes, continuous form format, with
record source a query off an Item Table. The fields are Category,
Subcategory, and Color. I am displaying descriptions, not ID''s, so I
have to convert the ID''s from various lookup tables.

The combo boxes work fine except for subcategory, which is dependent on
category. Depending on category, the drop-down box for subcategory
will display different items. (for example, when Category is
Furniture, Subcategory will display drop-down list of ''Dresser,
Nightstand, Desk...". Without clicking on the drop-down box,
subcategory will display in its text area the Description of the
subcategory ID of the existing record on the table.

The drop-down list for Subcategory works fine. However, the text
portion is blank for records on the 2nd category. In other words,
there are 10 records for the first category, Accessories. Subcategory
displays fine for these. But for the 11th record and subsequent
records, subcategory is blank (text portion, although drop-down works
correctly).

If I just display subcategory ID, and not convert to description, it
works fine.

My SQL statement for subcategory is:
"SELECT ItemSubcatID, ItemSubcatDesc FROM tlkpItemSubcategory
WHERE (((ItemCategoryID)=[Forms]![frmItems]![cboItemCategory]))
ORDER BY ItemSubcatDesc;"

Column count is 2, column width is 0, 2. Bound column is 1.
I think the problem lies around here. When I have column width =
"1,1", I can see that my subcatgegory ID is displayed correctly.

I do a requery of subcategory on category_afterupdate and
category_change... but the combo boxes drop-down part seem to be
working fine.

If I run just the query that''s the record source, it displays
subcategories correctly.

What would cause the text portion of my combo box to be blank?

Thanks in advance for any help,



I think you will find that your rowsource for the dependent combobox
is changed, on the fly, when you change the value of the combobox that
controls it.

When you modify the rowsource, you will find that any boxes which have
ID''s that are no longer in the rowsource will display as blank. This
is because while Access can display the underlying data if the
combobox is bound and the bound column is being displayed (even if
there is no match), if anything other than the bound column is being
displayed since the bound column does not have a match, the rest of
the columns are "undefined".

The "solution", such as it is (and it isn''t a very good one) is to
ensure that any dependent comboboxes have their bound columns equal to
the information you wish to display on the screen.

mike


Hi. Thank you both for your replies.

Steve:
I have just checked, and:
--Each record in the underlying query has a subcategory ID.
--all records that have subcategory ID have text in subcategory desc.
--I am not getting blank fields first. I get description for the first
category, then blanks for the 2nd category.

Mike:
Unless I am misunderstanding you, I don''t actually actively change the
recordsource. The situation I describe is happening when the form is
initially being populated with values from the table. When it fills the
form with data, subcategory is filled in correctly for the first
category, then it''s left blank when it is filling in data for the 2nd
category. I am not actually changing anything, just watching as the
form is being filled with data from the table. Does that make sense?

I am wondering if I am not correctly referencing the current CategoryID,
on this continuous form.

Thanks once again,
Lori


*** Sent via Developersdex http://www.developersdex.com ***


这篇关于组合框依赖于另一个组合框,文本部分为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆