Refreshing filter on subforms on pages

V

Vicki

I have a search form with 2 pages and 2 subforms. When I set the filter it
does not work unless I click on the page or hit the search twice. I put a
msg in the code and it shows the filter being set. I tried to do a requiry
on the subforms but got the same results. Below is a portion of the code.

Me.sbfrmTownCalls.Form.Filter = strWhereC
Me.sbfrmTownIssues.Form.Filter = strWhereI

Me.sbfrmTownCalls.Form.FilterOn = True
Me.sbfrmTownIssues.Form.FilterOn = True
MsgBox "Filter Set"

'DoCmd.Requery "SbFrmTownIssues"
'DoCmd.Requery "SbFrmTownCalls"
 
A

Allen Browne

You do have to set both the Filter and FilterOn.
(You should not need the Requery.)

This suggestion:
a) Checks to see if anything needs saving first.
b) Applies the filter and sets FilterOn before moving to the other subform.

With Me.sbfrmTownCalls.Form
If .Dirty Then .Dirty = False
.Filter = strWhereC
.FilterOn = True
End With
With Me.sbfrmTownIssues.Form
If .Dirty Then .Dirty = False
.Filter = strWhereI
.FilterOn = True
End With

If that still fails, something else must be interfering. For exmple, the
form may be being dirtied in Form_AfterUpdate or Form_Current, or a Timer
event could be messing it up.
 

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