remove filter

  • Thread starter Thread starter DeVille
  • Start date Start date
D

DeVille

Hi I have this combo box on my form 'cboCompanyName'. It
filters the record based on the value I select from the
drop down list. The only problem is that if the records
are already filtered it won't find the record I'm looking
for. I tried to attach a piece of code to the on got
focus event. However because this combo box is the first
in the tab order. When the form is opened it causes it
form to get into a loop where it gets stuck in a
flickering state. I tried shifting the tab order but that
didn't work either. If any one can suggest a better way
to fix this problem thanks in advance

Private Sub cboCompanyName _GotFocus()

DoCmd.ShowAllRecords

End Sub
 
Make sure that cboCompanyName is not bound (i.e. it has nothing in its
ControlSource) so that selecting a company is not dirtying the record.

Then test if the form's FilerOn property is True, and change it to false:
If Me.FilterOn Then
Me.FilterOn = False
End If

Before applying or removing a filter, it is also a good idea to explicitly
save the record:
If Me.Dirty Then
Me.Dirty = False
End If
 
Back
Top