Filter by Form

G

Guest

Hi,
I have a customer database and a form that allows additions/edits.
The user wants to be able to search on any of the fields on the form.
Ok, I have included a search button on the main screen and open the customer
form using VB as follows:
DoCmd.OpenForm "Find Customers"
RunCommand acCmdFilterByForm
I have placed 2 buttons on the form...1 to invoke the search once the user
has entered the required criteria and the second to basically switch the
filter off, close the form and go back to the main menu.
The problem I have is that these two buttons seem to be disabled i.e. I
cannot click on them to switch the filter on and off.
Am I doing this the wrong way?
What code should be behind these buttons to apply the fiter and then switch
it off?
Anyone any ideas?
Can you, using the above method apply filters on filters?
 
G

Guest

The problem I have is that these two buttons seem to be disabled i.e. I
cannot click on them to switch the filter on and off.

While the "Filter-by-form" feature is enabled, the form is set up only to
allow for search criteria to be added, not to handle events, such as the
click of a button. Therefore, all controls that can't contribute to the
search criteria, such as buttons, list boxes, unbound text boxes, et cetera,
will be disabled. When the criteria selection has been chosen and the filter
applied with the built-in "Apply Filter" toolbar button (which looks like a
silver filter), the records that meet the search criteria will be displayed
in the form, and the buttons, list boxes, and unbound controls will become
enabled again.

One can remove the filter applied to the form by selecting the "Remove
Filter" button (looks like a silver filter) on the built-in toolbar or by
using a button on the form created especially for this (of course, _after_
the "Filter-by-form" feature has been turned off and buttons are enabled
again). For example, in a new button's OnClick( ) event, try:

Me.FilterOn = False

To reapply a previously selected filter (the most previous search criteria)
using VBA code, in a button's OnClick( ) event, try:

Me.FilterOn = True
Can you, using the above method apply filters on filters?

Yes. Select the "Filter-by-form" button on the built-in toolbar (or your
form's "Filter-by-form" button) again and make additional selection criteria
using the combo boxes on the form. These selections can be in the same
fields or in additional fields. When finished selecting values in these
combo boxes, select the "Apply Filter" toolbar button to further filter the
currently filtered records.

Remember that the syntax LIKE "*anyWordHere*" can be used as criteria in
these combo boxes, too, so the user can be generic in a search and then start
narrowing it down with further filtering.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
G

Guest

Once again, thanks for your reply.
I was trying to do away with the menu & toolbars so that the user could not
do anything silly.....hence my own buttons to switch the filter on and off.
The filter icon is ok for teckies but not great for managers etc and its
also a toggle button i.e. on then off, on then off and so on.
Ah well, I'll bring back the toolbar icons and do it as you suggest.
Cheers
 
6

'69 Camaro

I was trying to do away with the menu & toolbars so that the user could
not
do anything silly

Create a custom toolbar that has only this button on it. Display this
custom toolbar and don't allow the built-in toolbar to display, so that the
users won't be tempted to play with whatever is available in the built-in
toolbar.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 

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