Hi there
I've got a reports form which filters a subform from three combo boxes, now working brilliantly thanks to help on a previous post. I was also given the code for a command button to open a report on the same filters. All good, except that the report only ever shows the first record from the filtered selection where I need it to show all relevant records. The query must be correct as it's the same source for the subform which does show more records. Is there something obvious I'm missing on the report setup? I can't see any groupings on the report but I am completely new to setting them up. Here's the code I was given for filtering:
Option Compare Database
Option Explicit
Sub cboDep_AfterUpdate()
FilterSub
End Sub
Sub cboBud_AfterUpdate()
FilterSub
End Sub
Sub cboSup_AfterUpdate()
FilterSub
End Sub
Private Sub FormHeader_Click()
End Sub
Private Sub Print_selection_Click()
DoCmd.OpenReport "Reports", acViewReport, , "[Purchase Order ID]=" & Me.ctrpurchases![Purchase Order ID]
End Sub
Sub FilterSub()
Dim sWhere As String
sWhere = "1=1"
If Not IsNull(cbodep) Then sWhere = sWhere & " and [Department Code]=" & cbodep
If Not IsNull(cbobud) Then sWhere = sWhere & " and [Finance Code]=" & cbobud
If Not IsNull(cbosup) Then sWhere = sWhere & " and [Supplier ID]=" & cbosup
If sWhere = "1=1" Then
Me.ctrpurchases.Form.FilterOn = False
Else
Me.ctrpurchases.Form.Filter = sWhere
Me.ctrpurchases.Form.FilterOn = True
End If
End Sub
I've started a new post as I marked the old one as Solved, if that was the wrong thing to do please let me know. All suggestions gratefully received, I'm afraid my coding is limited to direct copying.
Thanks!