I have a report in access that I need to only have employees (“Employee Number”) who have a specific criteria in two text boxes (and/or). So instead of pulling all the employees I would like to only pull employees that have an amount in these two text boxes. I have put the following code on the "Command6_Click" button and it is not working.
Dim strFilter As String
strFilter = "[Text1] >0 or [Text0]>0"
DoCmd.OpenReport "2011 Sick Abusers Letter Union Tbl 10~11 MM Report redo", acViewPreview, , strFilter
The Text Boxes are called Text1 and Text0 and I need the information greater than zero.
Also tried:
For Each [Employee Number] In Reports![2011 Sick Abusers Letter Union Tbl 10~11 MM Report redo]
If (Sum(Nz([1], 0)) + Sum(Nz([2], 0)) + Sum(Nz([3], 0)) + Sum(Nz([4], 0)) + Sum(Nz([5], 0)) + Sum(Nz([6], 0)) + Sum(Nz([7], 0)) + Sum(Nz([8], 0)) + Sum(Nz([9], 0)) + Sum(Nz([10], 0)) + Sum(Nz([11], 0)) + Sum(Nz([12], 0))) - 40 > 0 Or (Sum(Nz([7], 0)) + Sum(Nz([8], 0)) + Sum(Nz([9], 0)) + Sum(Nz([10], 0)) + Sum(Nz([11], 0)) + Sum(Nz([12], 0))) - 24 > 0 Then
Me![Employee Number].Visible = True
Else
Me![Employee Number].Visible = False
Next
End If
The query is a cross tab query which sets the date like this:
PIVOT Year([Date of Occurrence])*12+Format([Date of Occurrence],"mm")-(Year([Forms]![Sick Abusers List Pick From Form]![Start Date])*12+Format([Forms]![Sick Abusers List Pick From Form]![Start Date],"mm"))+1 In (1,2,3,4,5,6,7,8,9,10,11,12);
And then the Text Boxes are calculations from the Start Date to the End Date as follows:
=(Sum(Nz([7],0))+Sum(Nz([8],0))+Sum(Nz([9],0))+Sum(Nz([10],0))+Sum(Nz([11],0))+Sum(Nz([12],0)))-24
=(Sum(Nz([1],0))+Sum(Nz([2],0))+Sum(Nz([3],0))+Sum(Nz([4],0))+Sum(Nz([5],0))+Sum(Nz([6],0))+Sum(Nz([7],0))+Sum(Nz([8],0))+Sum(Nz([9],0))+Sum(Nz([10],0))+Sum(Nz([11],0))+Sum(Nz([12],0)))-40
Should I do a For Each statement? And how should I write the code? Not real good with VBA but am trying. Please help!!!
Dim strFilter As String
strFilter = "[Text1] >0 or [Text0]>0"
DoCmd.OpenReport "2011 Sick Abusers Letter Union Tbl 10~11 MM Report redo", acViewPreview, , strFilter
The Text Boxes are called Text1 and Text0 and I need the information greater than zero.
Also tried:
For Each [Employee Number] In Reports![2011 Sick Abusers Letter Union Tbl 10~11 MM Report redo]
If (Sum(Nz([1], 0)) + Sum(Nz([2], 0)) + Sum(Nz([3], 0)) + Sum(Nz([4], 0)) + Sum(Nz([5], 0)) + Sum(Nz([6], 0)) + Sum(Nz([7], 0)) + Sum(Nz([8], 0)) + Sum(Nz([9], 0)) + Sum(Nz([10], 0)) + Sum(Nz([11], 0)) + Sum(Nz([12], 0))) - 40 > 0 Or (Sum(Nz([7], 0)) + Sum(Nz([8], 0)) + Sum(Nz([9], 0)) + Sum(Nz([10], 0)) + Sum(Nz([11], 0)) + Sum(Nz([12], 0))) - 24 > 0 Then
Me![Employee Number].Visible = True
Else
Me![Employee Number].Visible = False
Next
End If
The query is a cross tab query which sets the date like this:
PIVOT Year([Date of Occurrence])*12+Format([Date of Occurrence],"mm")-(Year([Forms]![Sick Abusers List Pick From Form]![Start Date])*12+Format([Forms]![Sick Abusers List Pick From Form]![Start Date],"mm"))+1 In (1,2,3,4,5,6,7,8,9,10,11,12);
And then the Text Boxes are calculations from the Start Date to the End Date as follows:
=(Sum(Nz([7],0))+Sum(Nz([8],0))+Sum(Nz([9],0))+Sum(Nz([10],0))+Sum(Nz([11],0))+Sum(Nz([12],0)))-24
=(Sum(Nz([1],0))+Sum(Nz([2],0))+Sum(Nz([3],0))+Sum(Nz([4],0))+Sum(Nz([5],0))+Sum(Nz([6],0))+Sum(Nz([7],0))+Sum(Nz([8],0))+Sum(Nz([9],0))+Sum(Nz([10],0))+Sum(Nz([11],0))+Sum(Nz([12],0)))-40
Should I do a For Each statement? And how should I write the code? Not real good with VBA but am trying. Please help!!!