Private Sub Form_Load()
Dim rsc1, rsc2 As Integer
rsc1 = DCount("name", "chs")
rsc2 = DCount("*", "chs")
If rsc < rsc2 Then MsgBox "name记录有空值:" & rsc2 - rsc1 & "条"
End Sub
=DCount("*","表1","ID=1") =DCount("*","表1","名称='苹果'") =DCount("*","表1","日期=#2012/11/30#")
三种数据类型用法总结:
数值型表示法 " & 变量 & "
文本型表示法 '" & 变量 & "'
日期型表示法 #" & 变量 & "#
Dim rsc1 As Integer ' rsc2 rsc1 = DCount("*", "产品系列_TMP", "产品系列 IS NULL") ' rsc2 = DCount("*", "chs") If rsc1 > 0 Then MsgBox "产品系列记录有空值:" & rsc1 & "条,产品系列不允许有空值" Exit Sub End If rsc1 = DCount("*", "产品系列_TMP", "生产车间 IS NULL") ' rsc2 = DCount("*", "chs") If rsc1 > 0 Then MsgBox "生产车间记录有空值:" & rsc1 & "条,生产车间不允许有空值" Exit Sub End If
Me.生产部门.Value = DLookup("生产部门", "tbl_生产部门默认值", "Default=true")
多条件筛选
=DCount("*","dbo_TBL_ORDER","审核日期=#" & [订单导入日期] & "# and 生产部门='生产二部'")