DCount有2个条件 [英] DCount with 2 criteria

查看:151
本文介绍了DCount有2个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果数据表示错误,我正在使用DCount来帮助显示错误消息.我有一个标准,其中一个数字等于另一个数字.现在,我想在其中添加另一个条件,其中另一个字段ReturnDate(此字段为Text而不是Date/Time)等于连字符(-). 我只是不太确定如何格式化它.我有这个:

I am using DCount to help display an error message if the data signals an error. I have it working with one criteria where a number is equal to another number. Now I wanted to add another criteria in there where another field, ReturnDate (this field is Text not Date/Time) is equal to a hyphen (-). I'm just not really sure how to format it. I have this:

If DCount("*", "CrewTable", "KitNumber=" & _
  Me.AssignKit.Value And "ReturnDate=" & _
  "-") > 0 Then
  Cancel = True
  MsgBox "Kit is already assigned!"
  AssignKit = ""
  AssignKit.SetFocus
Else
...

错误弹出并显示类型匹配",调试器从"If->然后"突出显示整个语句,并出现错误,并指出引号中带有连字符的行.

The error pops up with a 'Type Mistmatch' and the debugger highlights the whole statment from 'If -> Then' and has an error pointing to the line with the hyphen in the quotes.

推荐答案

If DCount("*", "CrewTable", "ReturnDate='-' AND KitNumber=" & _
          Me.AssignKit.Value) > 0 Then

这篇关于DCount有2个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆