Filter question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When you filter on a form with a bound field, and the value filtered for does
not exists, Access is automatically placing the form in add mode. This is
confusing the heck out of my users.

Is there a general work around for this problem?
 
Leif said:
When you filter on a form with a bound field, and the value filtered
for does not exists, Access is automatically placing the form in add
mode. This is confusing the heck out of my users.

Is there a general work around for this problem?

Think of it this way. In an unfiltered form that allows additons you see a
Record Set that contains every row as well as the blank "new record" row at
the end. When you apply a filter that has no matches all rows except the
new one are filtered out. Then it makes perfect sense. Your form is not
really changing to "add mode" it is just filtering out all existing rows and
the new record row is all that remains.

You could build your own custom filter routine that "looks ahead" and just
displays a message if the new filter will result in no matches rather than
applying it.
 
I can see what you are saying. However, I would disagree on your statement
"...you see a Record Set that contains every row as well as the blank "new
record" row at the end". There is no blank record in the recordset. To get
a blank or new record you must click on the new record button in the record
navigator, add it from the menu, or add it programatically. Its not part of
the recordset.

There may be some people that appreciate this default behavior. In my case,
however, if the filter returns no records to display I would prefer if Access
gave a message to that affect, and returned you back to the pre-filter state.
However, since it does not work that way it appears I will need to implement
that behavior in code, which you mentioned, for every form.

Thanks,
Leif
 
Leif said:
I can see what you are saying. However, I would disagree on your
statement "...you see a Record Set that contains every row as well as
the blank "new record" row at the end". There is no blank record in
the recordset. To get a blank or new record you must click on the
new record button in the record navigator, add it from the menu, or
add it programatically. Its not part of the recordset.

That is how it is visually portrayed in a single view form, but open a datasheet
or a continuous view form and the "new record" row is clearly visible without
having to press the Go-To-New button. In fact even in a single view form you
can get to the new record position simply by pressing the "Next" button enough
times. It is clearly part of the RecordSet.
 
Try clicking on the last record button of the record navigator and see if you
see the blank record.

I could create a form with hundreds of blank lines, and add a new record
when the user started typing, but the hundreds of blank rows on a form do not
make hundreds of records in the recordset.

Open a table in VBA. Loop through the entire recordset until EOF is TRUE.
Tell me if you find the blank record.

Regards,
Leif
 
Leif said:
Try clicking on the last record button of the record navigator and
see if you see the blank record.

The new record position is not the "last record" so I don't see why pressing
the Go-To-Last button should take me there.
I could create a form with hundreds of blank lines, and add a new
record when the user started typing, but the hundreds of blank rows
on a form do not make hundreds of records in the recordset.

Open a table in VBA. Loop through the entire recordset until EOF is
TRUE. Tell me if you find the blank record.

My point is that it is part of the RecordSet "as presented to the user in a
form". Technical arguments aside I don't see what other default behavior
Access could use when you apply a filter with no matches. A filter is not
the same as a search (which does give a message when no match is found).
 
Back
Top