Form with two subreports

D

Dan

I am trying to requery one subreport (datasheet) and the other one ends up requering as well (without a filter-so shows all records, even though it may have already had a filter) (and vice versa). Here is the code I use to requery the first sub form. Essentially the form design contains 2 datasheets with a seperate filter and filter button for each.

Private Sub cmdFilterDept_Click()
Dim stFilter As String
Dim bNotFirst As Boolean
Dim bAtLeastOne As Boolean
frmDeptSubForm.Form.FilterOn = False
If Not IsNull(cboDepartment.Value) Then
stFilter = stFilter + "Dept='" & cboDepartment.Value & "'"
frmDeptSubForm.Form.FilterOn = True
bNotFirst = True
bAtLeastOne = True
End If
If Not IsNull(txtYearDept.Value) Then
If bNotFirst Then stFilter = stFilter + " AND "
stFilter = stFilter + "Year=" & txtYearDept.Value
frmDeptSubForm.Form.FilterOn = True
bAtLeastOne = True
End If
If bAtLeastOne = True Then
frmDeptSubForm.Form.filter = stFilter
End If
frmDeptSubForm.Requery
End Sub

Any ideas ?
 
D

Dan

I've discovered the problem.

Setting Filter On = false to one of the subforms caused it to be set for the other subform ...
I am trying to requery one subreport (datasheet) and the other one ends up requering as well (without a filter-so shows all records, even though it may have already had a filter) (and vice versa). Here is the code I use to requery the first sub form. Essentially the form design contains 2 datasheets with a seperate filter and filter button for each.

Private Sub cmdFilterDept_Click()
Dim stFilter As String
Dim bNotFirst As Boolean
Dim bAtLeastOne As Boolean
frmDeptSubForm.Form.FilterOn = False
If Not IsNull(cboDepartment.Value) Then
stFilter = stFilter + "Dept='" & cboDepartment.Value & "'"
frmDeptSubForm.Form.FilterOn = True
bNotFirst = True
bAtLeastOne = True
End If
If Not IsNull(txtYearDept.Value) Then
If bNotFirst Then stFilter = stFilter + " AND "
stFilter = stFilter + "Year=" & txtYearDept.Value
frmDeptSubForm.Form.FilterOn = True
bAtLeastOne = True
End If
If bAtLeastOne = True Then
frmDeptSubForm.Form.filter = stFilter
End If
frmDeptSubForm.Requery
End Sub

Any ideas ?
 

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