Link to home
Start Free TrialLog in
Avatar of michaeldi
michaeldi

asked on

Filtering By Selection

On my form I would like to make it when you click on a on click event it goes into "Filter By Form"

Also on this I notice that it gets rid of the headers and footers is there a way so that they stay visible because I would ideally like to put some buttons there.
Thankyou
Avatar of michaeldi
michaeldi

ASKER

Adjusted points from 30 to 70
Hello michaeldi,

Would you please give us more details.

Regards,
Paasky
2Well basiclly you know all the button on the toolbar,(ie the ones to do with Filter)

I just want to make up a command button so that when you press it, it does the same as it does as if you would have pressed it on the toolbar.

I am looking for the code to so when I click a button ie in my form footer it goes into "Filter By Form" mode

"Filter By Form" mode ie the mode that gives you the chance to use OR statements etc.

I basiclly need this to make my MDB more user friendly.
Can you or anybody paste me the code that would do this.

All of the other filter commands I found in the wizrds but not this one..

Thakyou in advance



Thanks for details, here's the button code:

Private Sub B_FilterByForm_Click()
    DoCmd.RunCommand acCmdFilterByForm
End Sub

Please let me know if this does not give you the desired result.

Paasky
Here are the two other filtering button DoCmd.RunCommand commands:

DoCmd.RunCommand acCmdFilterBySelection
DoCmd.RunCommand acCmdFilterExcludingSelection

Paasky
This will apply the filter:

DoCmd.RunCommand acCmdApplyFilterSort

There seems to be no way to avoid buttons been disabled when the filter mode is on - MS has build it to work that way.
You can have the points. I have two quick Questions.

Are you positive that you can not get it to see any buttons in that filterForm mode or shall i post it as another Question.

And just quickly is there a cmd command to load up the preloaded queries ie so when you click on :-

Private Sub B_FilterByForm_Click()
    DoCmd.RunCommand acCmdFilterByForm. load.the.the.pre.saved.queries.dialog.box.for.for.filter.

End Sub
in loads up the queries.
Thanks for all your help

ASKER CERTIFIED SOLUTION
Avatar of paasky
paasky
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One work-around solution for button-problem could be customized toolbar form, where you have all the buttons you want to be used with forms. To filter the particular form, you need to set focus to that form and then use DoCmd.RunCommand:

This code is from own toolbar form:

Private Sub B_FilterByForm_Click()


    On error resume next

    ' Set focus to other form
    Forms![TestForm].SetFocus

    ' this will work too: Forms("TestForm").Setfocus

    ' do filtering stuff here...
    DoCmd.RunCommand acCmdFilterByForm

End Sub

If you have save, delete, etc buttons, you just need to set focus to main form before using DoCmd.RunCommand acCmdSaveRecord, etc. commands.
I wanted to make is look all the same, mainly and have the Close button and Query button in the filter by form mode.
Because adventually when I finish the MDB i want to get rid of all standard tootlbars because only the relevant ones will be on the page they are in.

Thanks for the link and that code that will really help me.

If it cant be done then that is fair enough. If you do ever find out why you cant id be interested.

I will pose another Q to save you the hassle because explaining it will take some time.

Anyway thanks again for your help

Michaeldi






Glad I could assist you. I will post here comments if I hear anything new about the button issue.

Best regards,
Paasky