[英]Why Do i Get A Data Mismatch Error in my VBA Code
我最近添加了一個代碼,以紅色突出顯示用戶未填寫的文本框。 我還添加了一個代碼,用一個消息框提醒他們。 我有這個 dcount 代碼,但是當我按下運行按鈕執行查詢時,每當用戶將文本框留空時,我都會收到“條件表達式中的數據類型不匹配”。 你能幫我寫代碼嗎? 我在網上收到一個錯誤:
如果 DCount("*", "Final - Union Query 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
你需要為那個奇怪的表名加括號:
If DCount("*", "[Final - Union Query 07 & 08]") > 0 Then
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.