我最近添加了一个代码,以红色突出显示用户未填写的文本框。我还添加了一个代码,该消息将通过消息框提醒他们。我有这个dcount代码,但是当我按下运行按钮执行查询时,只要用户将文本框留空,我都会收到“条件表达式中的数据类型不匹配”的信息。您能帮我提供我的代码吗?我在网上遇到错误:
如果DCount(“ *”,“最终-联合查询07和08”)> 0然后
Private Sub Command2_Click()
If DCount("*", "Final - Union Query 07 & 08") > 0 Then
Me!results.Requery
ElseIf IsNull(Me.master_bill_a.Value) Or (Me.master_bill_a.Value = "")
Then
MsgBox ("All criteria must be filled in the form")
Me.master_bill_a.BorderColor = vbRed
DoCmd.GoToControl "master_bill_a"
ElseIf IsNull(Me.cash_date_a.Value) Or (Me.cash_date_a.Value = "") Then
MsgBox ("All criteria must be filled in the form")
Me.cash_date_a.BorderColor = vbRed
DoCmd.GoToControl "cash_date_a"
ElseIf IsNull(Me.billing_date_s) Then
MsgBox ("All criteria must be filled in the form")
Me.billing_date_s.BorderColor = vbRed
DoCmd.GoToControl "billing_date_s"
Else
MsgBox ("There are no results to display. This may be an overpayment or
the wrong information was entered in the form.")
End If
End Sub
答案 0 :(得分:0)
该怪异的表名需要使用方括号:
If DCount("*", "[Final - Union Query 07 & 08]") > 0 Then