?
Solved

Filtering By Selection

Posted on 2000-04-18
11
Medium Priority
?
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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
 
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 280 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

777 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