two filters one report

B

bfreeman

i have a report that i'm trying to filter with two list boxes. Bot
list boxes reside on the same form and i got the code below from th
previous developer of the database. It only seems to work if the lis
box values have a unique or id related to them....or maybe i'm missin
something. One listbox holds awards which has award ids and the othe
list box holds dates(yyyy). I cannot get the date list box to work
however i can filter the report based on the awards selected. I
someone has some better code or a idea that would help tremendously!



query for listbox values (awards):

Code
-------------------

SELECT DISTINCT qryAwards.AwardTypeID, qryAwards.AwardName
FROM qryAwards
GROUP BY qryAwards.AwardTypeID, qryAwards.AwardName;

-------------------


query for listbox values (date):

Code
-------------------

SELECT DISTINCT Format([DateReceived],"yyyy") AS [Date Received]
FROM qryAwards
GROUP BY Format([DateReceived],"yyyy");

-------------------


VB Code for Awards list box

Code
-------------------

Private Function GetCriteria() As String
Dim stDocCriteria As String
Dim VarItm As Variant
For Each VarItm In AwardList.ItemsSelected
stDocCriteria = stDocCriteria & "[AwardTypeID]= " & AwardList.Column(0, VarItm) & " OR "
Next
If stDocCriteria <> "" Then
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) - 4)
Else
stDocCriteria = "True"
End If

GetCriteria = stDocCriteria
End Function

Private Sub Command27_Click()
DoCmd.OpenReport "rptAwards", acPreview, , GetCriteria()
End Sub
 
B

bfreeman

i'm guessing from all of the replies to my post (zero) that no one ha
ever experienced or had a similar scenerio? Any help would b
appreciated.

ba
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top