Hi Viken,
Your post prompted me to experiment a bit more with filter by form. I don't
tend to use it myself. It is disabled in databases that I distribute to
users, because I think it's just too confusing for the average user. A few
minutes of frustration using the built-in Filter by Form confirms to me why I
invested the time a few years ago to learn the more powerful Query by Form
(QBF) technique, where one builds the WHERE portion of a SQL statement
on-the-fly, using VBA code. I can send you a sample database,if you are
interested in seeing a better mouse trap. If you are interested, send me a
private e-mail message with a valid reply-to address.
My e-mail address is available at the bottom of the contributor's page
indicated below. Please do not post your e-mail address (or mine) to a
newsgroup reply. Doing so will only attract the unwanted attention of
spammers.
I found some interesting results using the Orders and Order Details tables
in the sample Northwind database. First, lookup fields can be problematic.
This is confirmed in the following KB article (I added the parenthesis around
the title of this article, because it likely applies to Access 2002 and 2003
equally well):
(ACC2000
Filter By Form Options Do Not Apply to Lookup Fields
http://support.microsoft.com/?id=208573
Try applying a filter to the Employee field in the Orders table. This is a
nasty lookup field. You will receive an error message. This KB article
includes the following paragraph in the section titled More Information:
<Begin Quote>
"If the form's recordset contains more records than the number specified on
the Edit/Find tab of the Options command, then Microsoft Access does not fill
the combo box or list box with unique values from the form's recordset.
Rather, it fills the list with two values: Is Null and Is Not Null. The only
exception is when a field is a Lookup field (that is, when the field has its
DisplayControl property set to combo box or list box in an underlying table).
Then, Microsoft Access uses the table's RowSource property setting to fill
the value list for a Filter By Form combo box or list box, instead of reading
records from the form's recordset."
<End Quote>
In the Order Details table, I do indeed get Is Null and Is Not Null as the
only choices for the (5) fields. This table has over 2000 records in my copy
of Northwind. The setting that I had, under Tools > Options | Edit/Find tab
for the "Don't display list where more than this number of records read:"
setting was set to 1000. So, the result is consistent with the KB article.
I added a new text data type field to the Order Details table. I entered
"Joe", "Fred", "Barney", and "Tom" into the first four records. Select Filter
by Form on this field, and you get Is Null and Is Not Null as your only
choices. Now, go back into table design view, and set an Index (Duplicates
OK) on this field. Repeat the filter by form test, and you will likely see
that you get a filtered list that includes five records, one that looks blank
(represents most of the records, where you did not enter anything) and four
records with the unique names that you entered. However, now go back into
table design view, and change that Index to No Duplicates. Apply a Filter by
Form. The resulting combo dropdown appears to include one blank row for each
record in the table that is null. Not terribly useful.
By the way, if that was your *real* e-mail address that you included, you
should re-configure your newsreader so that it includes a munged form of your
e-mail address. Otherwise, you are extending a welcome mat to all the
spammers who harvest e-mail addresses from newsgroup posts. I removed your
e-mail address in this reply.
Tom Wickerath
Microsoft Access MVP
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________