如何根据选择改变组合框中的前色 [英] how to change forecolour in combo box based on selection

查看:62
本文介绍了如何根据选择改变组合框中的前色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个包含3个选项的组合框 - 红色,琥珀色和绿色。我已经写了一些代码(下面)我希望能改变盒子的前面颜色,这取决于选择了哪个选项,即红色=红色等等。我的代码可以在下面看到,我没有收到任何错误运行它,但是当选择一个选项并且在更新之前和更新之后都尝试了它时,前面的颜色没有改变。

Hi

I have a combo box with 3 options - Red, Amber and Green. I have wrote a bit of code (below) that I was hoping would change the fore colour of the box dependent on which option was selected, i.e. red = red etc. My code can be seen below, I am not getting any errors when I run it, but the fore colour is not changing when an option is selected and have tried it in both before update and after update.

展开 | 选择 | Wrap | 行号

推荐答案

嗯,你的代码在这里工作,我在Access 2003上。

在极少数情况下我需要这样的东西,我更喜欢改变组合框标题的颜色。而且我改变了背景而不是前景。
Well, your code is working here and I am on Access 2003.
On the rare occasions I needed something like that, I prefer to alter the color of the caption of the combo box instead. And I change the background instead of the foreground.





是的我弄清楚我做错了什么,现在它的工作除了一个事情。最好先给你一些背景我正在建立一个学生数据库基础,表格一次显示1个学生的详细信息,现在当我跳到下一个学生时,它会从前一页继续前面的颜色,即如果瞳孔被选为红色前面的颜色变为红色,但是当我跳到下一个瞳孔时,即使选项是绿色,前面的颜色也是红色!以下是新代码。

Hi

Yeah I figured out what I was doing wrong and its working now except for one thing. Best give you some background first I am building a pupil database base and the form shows 1 pupils details at a time, now when I skip to the next pupil it carries over the fore colour from the previous page i.e. if pupil one is selected as red the fore colour changes to red, however when I skip to the next pupil the fore colour is red even if the option is Green! Below is the new code.

展开 | 选择 < span class =codeDivider> | Wrap | 行号


这可能与表单的On current属性有关。基本上,当您从一个记录导航到另一个记录时,您必须检查组合框的值是什么,然后相应地设置颜色。
That probably has something to do with the On current property of the form. Basically, when you navigate from one record to another , you have to check what the value of the combo box is and then set the color accordingly.


这篇关于如何根据选择改变组合框中的前色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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