奇怪,我把代码改成如下,没有提示:
Dim Filter As String
With e.Form.Controls("姓名")
If .Value IsNot Nothing Then
Filter = "姓名 = '" & .Value & "'"
End If
End With
With e.Form.Controls("年月")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "年月 = '" & .Value & "'"
End If
End With
If Filter > "" Then
Tables("主管考勤月统计查询_Table1").Filter = Filter
End If
Tables("主管考勤月统计查询_Table1").Sort = "日期" '排序
Dim dd As WinForm.TextBox = e.Form.Controls("年月")
Dim dd1 As WinForm.TextBox = e.Form.Controls("姓名")
Dim Filter1 As String
With e.Form.Controls("姓名")
If .Value IsNot Nothing Then
Filter1 = "姓名 = '" & .Value & "'"
Else
Return
End If
End With
With e.Form.Controls("年月")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Dim d1 As Date = DataTables("主管考勤").Compute("min(日期)", "[姓名] = '" & dd1.text & "' And [年月] = '" & dd.text & "' ")
Dim dr As DataRow = DataTables("主管考勤").Find("[姓名] = '" & dd1.text & "' and [日期] = #" & d1.AddDays(-10) & "# ")
If dr IsNot Nothing Then
Filter1 = Filter1 & " And "
Else
Return
End If
Filter1 = Filter1 & "年月 = '" & dr("年月") & "'"
Else
Return
End If
Else
Return
End If
End With
'If Filter1 > "" Then
' Filter1 = Filter1 & " And "
'End If
'Filter1 = Filter1 & " 日期 >= #" & d1.AddDays(-6) & "# and 日期 <= #" & d1.AddDays(-1) & "# "
If Filter1 > "" Then
Tables("主管考勤月统计查询_Table2").Filter = Filter1
End If
Tables("主管考勤月统计查询_Table2").Sort = "日期" '排序