本文介绍了VBA:对ME的通用引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,


我想更改字段的背景颜色,因为它们是输入进行编辑的
。 (然后,当然,在退出时更改它们)


我的原型包括使用几个名为

EditColor和NormalColor的全局CONST。


我的事件代码如下:


Private Sub LastName_Enter()

Me!LastName.BackColor = EditColor

结束子


Private Sub LastName_Exit(取消为整数)

Me!LastName.BackColor = NormalColor

结束子


虽然这给了我正在寻找的效果,但似乎有
必须是一种更有效的方法来做到这一点。我认为我应该能够在代码模块中创建两个子程序,可以从所有字段事件(Enter和Exit)调用

并传递引用

当前字段。


我会称它们为ColorMeEdit和ColorMeNormal。


然后在现场输入事件,你只需要调用那个subrountine。

如果没别的话,这会大大减少打字的数量。


但是,我不知道如何通过

子程序的引用(到当前字段)。


有人能告诉我这样做的代码吗?


谢谢!

Greetings,

I would like to change the background color of fields as they are
entered for editing. (then, of course, change them back on exit)

My prototype consists of using a couple of global CONST called
EditColor and NormalColor.

I have event code as follows:

Private Sub LastName_Enter()
Me!LastName.BackColor = EditColor
End Sub

Private Sub LastName_Exit(Cancel as Integer)
Me!LastName.BackColor = NormalColor
End Sub

While this gives me the effect that Im looking for, it seems like there
has to be a more efficient way to do this. Im thinking that I should
be able to create two subroutines in a code module that can be called
from all the field events (Enter and Exit) and passing a reference to
the current field.

I would call them ColorMeEdit and ColorMeNormal for instance.

Then in the field Enter event, you would just call that subrountine.
That would dramtically reduce the amount of typing if nothing else.

But, I dont know how to pass a reference (to the current field) to the
subroutine.

Could someone show me code that would do this?

Thanks!

推荐答案




这篇关于VBA:对ME的通用引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 11:51