Search code examples
ms-accessvbasubform

Error 2467 filtering a subform in a form in a navigation


I have a form with 1 dropdown and 4 subreports, called rptBuildingResume. When I choose a value in the dropdown I filter all the subforms using that value. This works fine but...

I have a navigation form, called Main, when I add the previous form into my navigation form, of course I change my code, and this

2467 error

start to appear, but the fun thing is that it works fine for the first subreport, but fails for the next one. If I change the order of the callings it works allways fine for the first one, but fail in the next.

This is the code I´m using to do this:

[Forms]![Main]!SubformNav.[Form].rptNotFinishedBld.Report.Filter = "BuildingID_FK = " & Me.Building
[Forms]![Main]!SubformNav.[Form].rptNotFinishedBld.Report.FilterOn = True
[Forms]![Main]!SubformNav.[Form].rptNosPaidInFullBld.Report.Filter = "BuildingID_FK = " & Me.Building
[Forms]![Main]!SubformNav.[Form].rptNosPaidInFullBld.Report.FilterOn = True
[Forms]![Main]!SubformNav.[Form].rptDoneBld.Report.Filter = "BuildingID_FK >= " & Me.Building
[Forms]![Main]!SubformNav.[Form].rptDoneBld.Report.FilterOn = True
[Forms]![Main]!SubformNav.[Form].rptAgreeDepositNoStartBld.Report.Filter = "BuildingID_FK = " & Me.Building
[Forms]![Main]!SubformNav.[Form].rptAgreeDepositNoStartBld.Report.FilterOn >= True
  • Main is my navigation form.
  • SubformNav is the subform in it.
  • rpt* are the subreports in the subform.

Solution

  • If this is an inbuilt navigation form then it is caused by the way the inbuilt Navigation form work - I would have a read here https://www.access-programmers.co.uk/forums/showthread.php?t=286675 for some explanations of Cause and effect.

    If not then you need to look at the syntax examples here http://access.mvps.org/access/forms/frm0031.htm for the correct way to reference sub forms from other forms / subforms.

    Edit: The alternative would be to use the Child/Master properties of the subreports to negate having to filter them, probably more efficient as well.