我正在尝试验证输入文本框时的产品代码。我似乎想不出一种方法来抛出一个消息框,说明没有输入任何内容。
Me.txt_Product = UCase(Me.txt_Product)
If Not IsNull(upProd) Then
If DCount("Validation_Test", "Validation_Testing_Table", "[Validation_Test] = '" & UCase(Me.txt_Product) & "'") >= 1 Then
MsgBox "User Name Found!"
ElseIf Me.txt_Product.Value = "" Then
MsgBox "You Did Not Enter a Product Code!"
Else
MsgBox "User Name Not Found!"
End If
End If对于DCount的帮助或其他方式,有什么建议吗?
发布于 2018-03-28 15:17:01
我怀疑textbox为Null,并且测试空字符串失败。处理Null或空字符串的可能性:
ElseIf Me.txt_Product.Value & "" = "" Then
将Null与"“(空字符串)连接将返回空字符串。
发布于 2018-03-28 15:34:33
您可以创建更好的逻辑流程:
Me!txt_Product.Value = UCase(Me!txt_Product.Value)
If Not IsNull(upProd) Then
If Nz(Me!txt_Product.Value) = "" Then
MsgBox "You Did Not Enter a Product Code!"
Else
If IsNull(DLookup("Validation_Test", "Validation_Testing_Table", "[Validation_Test] = '" & Me!txt_Product.Value & "'")) Then
MsgBox "User Name Not Found!"
Else
MsgBox "User Name Found!"
End If
End If
End If当心那些感叹号。用户不会被大喊大叫就能理解信息。
https://stackoverflow.com/questions/49525626
复制相似问题