Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-08-2005, 01:15 AM   #1
naminder
Registered User
 
Join Date: Aug 2005
Location: UK, Leeds, West Yorkshire
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
naminder is an unknown quantity at this point
Filter By Selection Button on Form

Hi, I am trying to find code that will let me put a command button on a search form. When it is clicked I want the command filter by selection to filter the records. Basically copying the command when you click the button on the toolbar

naminder is offline   Reply With Quote
Old 08-08-2005, 02:31 AM   #2
Oldsoftboss
AWF VIP
 
Oldsoftboss's Avatar
 
Join Date: Oct 2001
Location: in the shed
Posts: 2,504
Thanks: 0
Thanked 57 Times in 49 Posts
Oldsoftboss will become famous soon enough
Try:

DoCmd.RunCommand acCmdFilterBySelection

when you type "DoCmd.RunCommand", after pressing the space bar, a list of members of the group. Another way is to search the object browser by typing accmd to the search box. A list of all members will be displayed.

Dave
__________________
Apathy is on the increase, but who cares.

Imagine if there were no hypothetical questions

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Oldsoftboss is offline   Reply With Quote
Old 08-08-2005, 02:50 AM   #3
naminder
Registered User
 
Join Date: Aug 2005
Location: UK, Leeds, West Yorkshire
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
naminder is an unknown quantity at this point
hi there!

cheers for that. Im using Access 2003 and that code throws errors. saying can't find. figured it was something to do with setfocus. Anyway code below sorted it!!!

Private Sub cmdFilterSelect_Click()
On Error Goto ErrHandler
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFilterBySelection
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2046 'Filter not available at moment
MsgBox "Command not available"
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
End Select
End Sub

naminder is offline   Reply With Quote
Old 08-10-2005, 01:25 AM   #4
Oldsoftboss
AWF VIP
 
Oldsoftboss's Avatar
 
Join Date: Oct 2001
Location: in the shed
Posts: 2,504
Thanks: 0
Thanked 57 Times in 49 Posts
Oldsoftboss will become famous soon enough
Cheers

Dave
__________________
Apathy is on the increase, but who cares.

Imagine if there were no hypothetical questions

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Oldsoftboss is offline   Reply With Quote
Old 07-09-2007, 06:04 AM   #5
kanikedude03
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kanikedude03 is on a distinguished road
Can't get this to work

Hello, i'm trying to get this to work also. I tried the code posted and it throws up an error with both sets of code. I'm using Access 2003. Any idea what i might be doing wrong? I added a command button, went to build event, Code Builder, then pasted the code. I just need to know what i'm doing wrong. Thanks everyone.
kanikedude03 is offline   Reply With Quote
Old 02-18-2018, 06:43 AM   #6
eirman
Newly Registered User
 
eirman's Avatar
 
Join Date: Aug 2013
Location: Ireland
Posts: 38
Thanks: 14
Thanked 3 Times in 3 Posts
eirman is on a distinguished road
Re: Filter By Selection Button on Form

With the built-in Filter By Selection tool on the ribbon/toolbar, you can filter by selection on PART of a field.

In this example field [THE BIG BLUE HOUSE]
With the Filter By Selection Tool you can search for BIG or BIG BLUE.

However, naminder's code works by filtering By Selection of the whole field.

Could someone improve the code so that it emulates built-in Filter By Selection tool.

(I'm using Access 2013)

__________________
Regards, David
eirman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Close Form button not firing Sorrells Forms 2 09-09-2002 12:49 PM
re: I need to make a filter by form button homer2002 Forms 1 08-28-2002 02:51 PM
filter by selection button Purdue22 Modules & VBA 1 06-26-2001 10:25 AM
How do I show filter command on form, not query joe789 Forms 0 06-11-2001 11:58 AM
[SOLVED] Clearing the filter form Leigh Forms 1 12-01-2000 05:42 PM




All times are GMT -8. The time now is 05:02 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World