|
子窗体中“交付日期”最大是2019年9月30日,查询时在窗体上录入2019年9月30日即正常,如录入时间为2019年10月1日以后,查询结果就为0。这时为什么呢?需要怎么改代码呢?谢谢各位大侠!!!
Private Sub 查询_Click()
Dim strSQL As String
Dim strWhere As String
Dim ctl As Control
Dim varI As Variant
strSQL = "select * from 合并表 where True "
If Me.名称.ItemsSelected.Count > 0 Then
Set ctl = Me.名称
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQL = strSQL & " And 名称 in (" & Left(strWhere, Len(strWhere) - 1) & ") "
End If
If Me.状态.ItemsSelected.Count > 0 Then
Set ctl = Me.状态
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQL = strSQL & " And 状态 in (" & Left(strWhere, Len(strWhere) - 1) & ") "
End If
strSQL = strSQL & IIf(IsNull(Me.站点名称), "", " and [C铁塔站名] like'*" & Me.站点名称 & "*'")
strSQL = strSQL & IIf(IsNull(Me.日期开始), "", " and [交付日期]>=#" & Me.日期开始 & "#")
strSQL = strSQL & IIf(IsNull(Me.日期截止), "", " and [交付日期]<=#" & Me.日期截止 & "#")
Debug.Print strSQL
Me.CRMPMS报表子窗体.Form.RecordSource = strSQL
End Sub |
|