Private Sub cmd查询1_Click()
Dim strWhere As String '定义条件字符串
Dim Rs As New ADODB.Recordset
Dim Sql As String
strWhere = ""
If Not IsNull(Me.Text35) Then
strWhere = strWhere & "[注册号]= '" & Me.Text35 & "' AND "
End If
If Not IsNull(Me.日期开始) And Not IsNull(Me.日期截止) Then
strWhere = strWhere & "[日期] BETWEEN #" & Format(Me.日期开始, "yyyy-mm-dd") & "# and #" & Format(Me.日期截止, "yyyy-mm-dd") & "# and "
End If
If Not IsNull(Me.日期开始) And IsNull(Me.日期截止) Then
strWhere = strWhere & "[日期]>=#" & Format(Me.日期开始, "yyyy-mm-dd") & "# and "
End If
If IsNull(Me.日期开始) And Not IsNull(Me.日期截止) Then
strWhere = strWhere & "[日期]<=#" & Format(Me.日期截止, "yyyy-mm-dd") & "# and "
End If
If Len(strWhere) > 0 Then
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
Me.MA60飞行时间子窗体.Form.Filter = strWhere
Me.MA60飞行时间子窗体.Form.FilterOn = True
..............(后面的代码一样,省略复制了)