逻辑上有错误,点击统计的时候,应该是根据输入的内容统计。
点击半年、一年的时候,另外统计,不要放在统计按钮里做。
如果要做也行,点击半年、一年的时候,自动给开始日期、结束日期赋值即可。
If zm.Value="请选择部门" Then
MessageBox.show("您没有选择部门啊,怎么统计?")
Else
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
With e.Form.Controls("stardate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("enddate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("表a").Filter = Filter
End If
End If