我会假设的东西会出现很多...
我想知道是否有办法在Access的条件格式中格式化所有空白字段。在我的情况下,通常需要输入所有字段,但并非在所有情况下都是。所以,与其写一堆条件代码来限制用户写在那里,我只是想在我的领域中出现一些红色背景作为提醒:“嘿,这里什么都没有......当然,那是你想要的吗?”
这是在平板电脑上,所以消息框会很烦人。所以条件格式化是。我知道你可以有'空'([场]),但这需要我通过30+场上的20+表格,并确保适当的字段名称等,然后单独为他们输入条件。有没有一种方法可以简单地多选我的领域,做一个条件格式在多个,并使用可能是“等于:NULL”?
我试过“等于:空”,它不工作..也不“等于:“”“(使用访问常量)想法为什么?或者我怎么解决这个问题?另外,它只对非触摸字段是必需的,所以如果用户开始键入然后删除回到空白,我不如果有更好的方法来做到这一点我所有的眼睛是空的条件格式 - MS Access窗体
编辑:我已经开始做一些VBA代码,我将粘贴到我的所有窗体中:
Private Sub Form_Load()
Dim ctl As Control
Dim reqCol As Long
Dim focusCol As Long
Dim doneCol As Long
Dim format As FormatCondition
reqCol = RGB(246, 180, 180)
focusCol = RGB(252, 249, 238)
doneCol = RGB(255, 255, 255)
For Each ctl In Me.Controls
With ctl
Me.Controls(ctl.Name).FormatConditions.Delete 'Delete the existing conditions.
Me.Controls(ctl.Name).BackColor = doneCol 'Set the background color to the done color.
Select Case .ControlType
Case acTextBox
'Create the format objects.
format = Me.Controls(ctl.Name).FormatConditions.Add(acFieldValue, acEqual, "")
format = Me.Controls(ctl.Name).FormatConditions.Add(acFieldHasFocus)
'Format the filled in boxes (ie set back to red)
With Me.Controls(ctl.Name).FormatConditions(0)
.BackColor = reqCol
.Enabled = True
End With
'Format the current field color (ie set to beige)
With Me.Controls(ctl.Name).FormatConditions(1)
.BackColor = focusCol
.Enabled = True
End With
End Select
End With
Next ctl
End Sub
问题是FormatConditions.Add(acFieldValue, acEqual, "")
出于同样的原因不起作用......我该如何解决这个问题?看到VBA和内置条件都有缺陷,看起来像一个错误。或者我在我面前丢失了一些东西。
将null与空字符串连接总是会产生一个空字符串。 'len([Fieldname]&“”)= 0'是否适合你的任务? – SeanC
不是真的..它仍然留下了一个事实,即我必须为每个字段手动输入[Fieldname]。我需要批量解决方案。我已经开始在VBA中编写它,但它也有同样的问题。将更新问题。 – StuckAtWork