MS Access 中的文本框前景色更改
Textbox ForeColor change in MS Access
情况:我在 MS Access 2010
中有一个表单,其中包含大约 50 个文本框和组合框,它们的 ForeColor
设置为 Load
上的 11250603 Gray
。我想要做的是创建一段简洁的代码,将单个选择的 ForeColor
更改为 vbBlack
。
我可以为每个 text/combo 使用 GotFocus
事件,但这很笨拙。我已经看到其他使用了 DirectCast()
的模糊相似的线程,但这不是我所知道的,我什至不确定它是否会在 MS Access 2010
中工作。我已经尝试过 YouTube 和搜索主题,但到目前为止还没有找到解决方案。
如果有人能指出我在哪里可以找到代码或可以在哪里改编代码的正确方向,我将不胜感激。
您将使用 WithEvents。示例如下:
Create Windows Phone Colour Palette and Selector using WithEvents
它包含这个简单的代码:
Private Sub ClassTextBox_Click()
' Select full content.
ClassTextBox.SelStart = 0
ClassTextBox.SelLength = Len(ClassTextBox.Value)
' Display the clicked value.
ClassTextBox.Parent!CopyClicked.Value = ClassTextBox.Value
' Copy the clicked value to the clipboard.
DoCmd.RunCommand acCmdCopy
End Sub
到 select 并为单击的任何文本框复制一个值。您可以将其修改为 设置前景颜色:
Private Sub ClassTextBox_Click()
' Set foreground colour.
ClassTextBox.ForeColor = vbBlack
End Sub
在 Load 事件中,您可以将前景色设置为您的灰度值。
情况:我在 MS Access 2010
中有一个表单,其中包含大约 50 个文本框和组合框,它们的 ForeColor
设置为 Load
上的 11250603 Gray
。我想要做的是创建一段简洁的代码,将单个选择的 ForeColor
更改为 vbBlack
。
我可以为每个 text/combo 使用 GotFocus
事件,但这很笨拙。我已经看到其他使用了 DirectCast()
的模糊相似的线程,但这不是我所知道的,我什至不确定它是否会在 MS Access 2010
中工作。我已经尝试过 YouTube 和搜索主题,但到目前为止还没有找到解决方案。
如果有人能指出我在哪里可以找到代码或可以在哪里改编代码的正确方向,我将不胜感激。
您将使用 WithEvents。示例如下:
Create Windows Phone Colour Palette and Selector using WithEvents
它包含这个简单的代码:
Private Sub ClassTextBox_Click()
' Select full content.
ClassTextBox.SelStart = 0
ClassTextBox.SelLength = Len(ClassTextBox.Value)
' Display the clicked value.
ClassTextBox.Parent!CopyClicked.Value = ClassTextBox.Value
' Copy the clicked value to the clipboard.
DoCmd.RunCommand acCmdCopy
End Sub
到 select 并为单击的任何文本框复制一个值。您可以将其修改为 设置前景颜色:
Private Sub ClassTextBox_Click()
' Set foreground colour.
ClassTextBox.ForeColor = vbBlack
End Sub
在 Load 事件中,您可以将前景色设置为您的灰度值。