Notiophilus
Registered User.
- Local time
- Today, 21:08
- Joined
- Jan 18, 2015
- Messages
- 42
I have a search form which suddenly stopped remembering filters between loads. I managed to accidentally replicate the behaviour on a second database where I knew the filters worked - in this case the code was
Turns out that simply commenting out then uncommenting this section (while the form was open) was enough to break it. Filtering still works, but the form's filter property is forgotten when it unloads, and the only way to change it permanently is in Design View.
So I made a very simple test db with a filtered form, started faffing around with the code while it was open, and lo and behold the filters have stopped working. But I've compared the functional and non-functional versions and I can't for the life of me see what's been changed. I suspect I've run into some kind of bug (not that I should be fiddling with code while in form view anyway) but what can I do to revert it?
It turns out that I can force the filter to be saved by hitting Ctrl+S before I exit the form. Still no clue as to why v1 mysteriously works and v2 mysteriously doesn't.
In the meantime, can I replicate Ctrl+S in VBA? I tried DoCmd.Save acForm "FormName", but no luck there.
Code:
Private Sub Form_Unload(Cancel As Integer)
Me.Filter = "(False)"
Me.FilterOn = True
End Sub
So I made a very simple test db with a filtered form, started faffing around with the code while it was open, and lo and behold the filters have stopped working. But I've compared the functional and non-functional versions and I can't for the life of me see what's been changed. I suspect I've run into some kind of bug (not that I should be fiddling with code while in form view anyway) but what can I do to revert it?
It turns out that I can force the filter to be saved by hitting Ctrl+S before I exit the form. Still no clue as to why v1 mysteriously works and v2 mysteriously doesn't.
