Solved

Filtering By Selection

Posted on 2000-04-18
11
215 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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

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.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

730 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