Hi all,i will strongly appreciate if someone could help me,to figure out how i can handel my problem.
I have this report :" RequirementQuer y_Report" and i have a command button that opens this report according certain conditions.
My report hodls all information regarding the requirements in my database such as the producs,status, and release version( this last three are listed in a listbox each)
so whenever i select a certain product,with a certain status and a certain release value i will get the report.
But my problem is, some requirements have 2 products and whenever i select one of those products i do not want to have that requirements because it has an other product.but whenever i select both product then i wanna see the requirement.
Here below is the code i wrote,it works only when i select one of the product that a requirement has.
could some one help me figure out how to handle that.
i think it should be a sql command with a where clause but i do not know what to writte in there.
[CODE=vb]Private Sub Generate_Report _Click()
Dim var As Variant ' Product Selected
Dim status As Variant ' Status selected
Dim Release As Variant 'Release version selected
Dim strf As String ' holds Report filter
Dim iCounter As Integer 'a counter
iCounter = 1 'Initialize it to 1 to be able to compare it with the last selected item
If Not IsNull(var) Then
If Not IsNull(status) Then
If Not IsNull(Release) Then
strf = " ( "
For Each var In Me.ProductList. ItemsSelected
strf = strf + "RequirementQue ry.ProductTag = '" + (Me.ProductList .Column(1, var)) + "' "
If iCounter < Me.ProductList. ItemsSelected.C ount Then ' As long as icounter<the last Prod selected; add OR
strf = strf + "OR "
End If
iCounter = iCounter + 1
Next var
strf = strf + " ) AND ( "
iCounter = 1 'Initialize icounter again otherwise it will still have the previous value
For Each status In Me.StatusList.I temsSelected
strf = strf + "RequirementQue ry.StatusTag= '" + (Me.StatusList. Column(1, status)) + "'"
If iCounter < Me.StatusList.I temsSelected.Co unt Then ' As long as iCouter< the last status selected add OR
strf = strf + " OR "
End If
iCounter = iCounter + 1
Next status
strf = strf + " )"
strf = strf + " AND ( "
iCounter = 1
For Each Release In Me.ReleaseList. ItemsSelected
strf = strf + "RequirementQue ry.ReleaseVersi on= '" + (Me.ReleaseList .Column(1, Release)) + " ' "
If iCounter < Me.ReleaseList. ItemsSelected.C ount Then
strf = strf + " OR "
End If
iCounter = iCounter + 1
Next Release
strf = strf + " )"
DoCmd.OpenRepor t "RequirementQue ry_Report", acViewPreview, , "( " + strf + " )"
Else
MsgBox "Provide a Release version"
Exit Sub
End If
Else
Exit Sub
End If
End If
End sub[/CODE]
Please help.
Best Regards,
Joelle
I have this report :" RequirementQuer y_Report" and i have a command button that opens this report according certain conditions.
My report hodls all information regarding the requirements in my database such as the producs,status, and release version( this last three are listed in a listbox each)
so whenever i select a certain product,with a certain status and a certain release value i will get the report.
But my problem is, some requirements have 2 products and whenever i select one of those products i do not want to have that requirements because it has an other product.but whenever i select both product then i wanna see the requirement.
Here below is the code i wrote,it works only when i select one of the product that a requirement has.
could some one help me figure out how to handle that.
i think it should be a sql command with a where clause but i do not know what to writte in there.
[CODE=vb]Private Sub Generate_Report _Click()
Dim var As Variant ' Product Selected
Dim status As Variant ' Status selected
Dim Release As Variant 'Release version selected
Dim strf As String ' holds Report filter
Dim iCounter As Integer 'a counter
iCounter = 1 'Initialize it to 1 to be able to compare it with the last selected item
If Not IsNull(var) Then
If Not IsNull(status) Then
If Not IsNull(Release) Then
strf = " ( "
For Each var In Me.ProductList. ItemsSelected
strf = strf + "RequirementQue ry.ProductTag = '" + (Me.ProductList .Column(1, var)) + "' "
If iCounter < Me.ProductList. ItemsSelected.C ount Then ' As long as icounter<the last Prod selected; add OR
strf = strf + "OR "
End If
iCounter = iCounter + 1
Next var
strf = strf + " ) AND ( "
iCounter = 1 'Initialize icounter again otherwise it will still have the previous value
For Each status In Me.StatusList.I temsSelected
strf = strf + "RequirementQue ry.StatusTag= '" + (Me.StatusList. Column(1, status)) + "'"
If iCounter < Me.StatusList.I temsSelected.Co unt Then ' As long as iCouter< the last status selected add OR
strf = strf + " OR "
End If
iCounter = iCounter + 1
Next status
strf = strf + " )"
strf = strf + " AND ( "
iCounter = 1
For Each Release In Me.ReleaseList. ItemsSelected
strf = strf + "RequirementQue ry.ReleaseVersi on= '" + (Me.ReleaseList .Column(1, Release)) + " ' "
If iCounter < Me.ReleaseList. ItemsSelected.C ount Then
strf = strf + " OR "
End If
iCounter = iCounter + 1
Next Release
strf = strf + " )"
DoCmd.OpenRepor t "RequirementQue ry_Report", acViewPreview, , "( " + strf + " )"
Else
MsgBox "Provide a Release version"
Exit Sub
End If
Else
Exit Sub
End If
End If
End sub[/CODE]
Please help.
Best Regards,
Joelle
Comment