Solved

Filtering By Selection

Posted on 2000-04-18
11
210 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:michaeldi
  • 7
  • 4
11 Comments
 
LVL 1

Author Comment

by:michaeldi
ID: 2725900
Adjusted points from 30 to 70
0
 
LVL 10

Expert Comment

by:paasky
ID: 2727733
Hello michaeldi,

Would you please give us more details.

Regards,
Paasky
0
 
LVL 1

Author Comment

by:michaeldi
ID: 2728593
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



0
 
LVL 10

Expert Comment

by:paasky
ID: 2728620
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
0
 
LVL 10

Expert Comment

by:paasky
ID: 2728625
Here are the two other filtering button DoCmd.RunCommand commands:

DoCmd.RunCommand acCmdFilterBySelection
DoCmd.RunCommand acCmdFilterExcludingSelection

Paasky
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 10

Expert Comment

by:paasky
ID: 2728649
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.
0
 
LVL 1

Author Comment

by:michaeldi
ID: 2730066
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

0
 
LVL 10

Accepted Solution

by:
paasky earned 70 total points
ID: 2730151
I had some buttons in my test form header and footer, and when I pressed FilterByForm button, all buttons (including those which were in detail section) were disabled in FilterByForm mode - but they didn't disappear. If you like, I can ask second opinion from other expert about this issue - and of course you can do that yourself if you want more opinions.

BTW, just curious, what button actions you want to be enabled during the time the form is in filter mode? Is it bad that buttons are disabled?

You can have only one parameter with DoCmd.RunCommand function: the action (you can see the full list of action constants looking for Access help using keywords "RunCommand Method Constants".

Here's a link you find very useful information about RunCommand actions:

http://home.clara.net/tkwickenden/

As requested, here's the code which sets form to filter mode and opens the query dialog:

Private Sub B_FilterByForm_Click()
   
    ' handle possible error messages
    ' for eg. user press 'Cancel' button
    ' instead of choosing any query

    On error resume next

    ' Enter filter by form mode
    DoCmd.RunCommand acCmdFilterByForm

    ' Show available queries
    DoCmd.RunCommand acCmdLoadFromQuery

End Sub

Hope this helps,
paasky
0
 
LVL 10

Expert Comment

by:paasky
ID: 2730176
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.
0
 
LVL 1

Author Comment

by:michaeldi
ID: 2730210
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






0
 
LVL 10

Expert Comment

by:paasky
ID: 2730405
Glad I could assist you. I will post here comments if I hear anything new about the button issue.

Best regards,
Paasky
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now