代码整理如下:
例一
.WhereSQL = "生产日期=date()"
.QueryConditions = "生产日期默认等于" & Date
.RunQuery
例二
.WhereSQL = "生产日期=#2017-02-13#"
.QueryConditions = "生产日期默认等于2017-02-13"
.RunQuery
例三
Dim d月初 As Date
Dim d月末 As Date
d月初 = DateSerial(Year(Date), Month(Date), 1)
d月末 = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
Set mclsQuery = New GeneralQuery
With mclsQuery
.QueryForm = Me.sfrQuickQuery.Form
.DataForm = Me.sfrList.Form
.AddAllFields
.FieldName = "规格"
.WhereSQL = "生产日期 between #" & d月初 & "# And #" & d月末 & "#"
.QueryConditions = "生产日期默认等于当月(" & d月初 & "-" & d月末 & ")"
.RunQuery
End With
例四
.FixedWhereSQL = "[bxrq]>=DateAdd('d',-60,Date()) "
.FixedQueryConditions = "([报销日期]在60天内记录)"
.RunQuery
例五
.WhereSQL = "[状态]<>'已完成'"
.QueryConditions = "([状态] 不等于 ""已完成"")"
.RunQuery