如果数据不在表中,请更改组合框的颜色 [英] Change the color of a Combo box if data is not in the table

查看:37
本文介绍了如果数据不在表中,请更改组合框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为Compounds的表单,其中包含一个包含代码的下拉列表(1)。第二个下拉列表(2)链接到第一个,并包含所选代码的组名。如果所需的组名不在此列表中,则用户仍可以添加它,但它不会出现在Code表中(但在Compound表中是的)。我不想要它的原因是它必须首先被确认为有效。那么当它包含的名称与代码名称不同时,如何更改下拉列表2的颜色(让我们说为红色)。或者换句话说,代码没有这样的名字。


表格:化合物


下拉列表1.显示代码。

Combo586

控制来源:FracCode

行来源:SELECT DISTINCT [List Frac code] .FracCode FROM [List Frac code];

限制列表:是


下拉列表2.显示组名

Combo633

控制来源:GroupName

行来源:SELECT DISTINCT [List Frac code] .GroupName FROM [List Frac code] WHERE([FracCode] = [combo586])ORDER BY [GroupName];

限制列表:否

I have a Form called Compounds with a dropdown list (1) containing Codes. A second dropdown list (2) is linked to the 1st, and contains Group Names for the Code chosen. If the Group Name needed is not on this list the user can still add it but it will not appear in the Code table (but yes in the Compound table). The reason I don’t want it there yet is that it has to be confirmed as valid first. So how can I change the colour of dropdown list 2 (let’s say to red) when the name it contains is different from the ones of the Code. Or in other words, the Code has no such name.

Form: Compounds

Dropdown list 1. Shows the codes.
Combo586
Control Source: FracCode
Row Source: SELECT DISTINCT[List Frac code].FracCode FROM[List Frac code];
Limit to list: yes

Dropdown list 2. Shows the Group Names
Combo633
Control Source: GroupName
Row Source: SELECT DISTINCT[List Frac code].GroupName FROM[List Frac code] WHERE ([FracCode]=[combo586]) ORDER BY [GroupName];
Limit to list: no

推荐答案

当这样的未经验证时,我会使第二个组合框不可见代码被选中。

最好不要首先显示这些代码,但是如果你想要显示它们,我可能会添加一个命中的计数。第二个组合如:

codeA(2)

codeB(0)

codeC(4)

等等。


为了使第二个组合不可见,您可以使用第一个组合的AfterUpdate事件,如:
I would make the second combobox invisible when such a "not validated" code is chosen.
Best would be not to show such codes in the first place, but if you want to show them, I would probably add a count of the "hits" of the second combo like:
codeA (2)
codeB (0)
codeC (4)
etc..

For making the second combo invisible you can use the AfterUpdate event of the first combo like:
展开 | 选择 | Wrap | 行号



当这样的未经验证时,我会使第二个组合框不可见。代码被选中。

最好不要首先显示这些代码,但是如果你想要显示它们,我可能会添加一个命中的计数。第二个组合如:

codeA(2)

codeB(0)

codeC(4)

等等。


为了使第二个组合不可见,您可以使用第一个组合的AfterUpdate事件,如:
I would make the second combobox invisible when such a "not validated" code is chosen.
Best would be not to show such codes in the first place, but if you want to show them, I would probably add a count of the "hits" of the second combo like:
codeA (2)
codeB (0)
codeC (4)
etc..

For making the second combo invisible you can use the AfterUpdate event of the first combo like:
展开 | 选择 | Wrap | 行号


你需要使用combo1(586)的值来设置combo2(633)是否可见。

因此我在IF语句中使用了combo586的值组合1的后续更新,因为该选择定义或组合2的价值.....


(最好给组合名称而不是使用数字,如cmbCode和cmbGroupname。)


Nic; o)
You need to use the value of combo1 (586) to set combo2 (633) visible or not.
Thus I used the value of combo586 in the IF statement of the afterupdate of combo 1, as that choice defines or there''s a value for combo 2.....

(Best to give a combo a name instead of using a number, like cmbCode and cmbGroupname.)

Nic;o)


这篇关于如果数据不在表中,请更改组合框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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