Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2004, 05:34 PM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default ApplyFilter on a Subform

Hi there!

I have a simple question. How can I apply a filter to a subform, clicking a toggle button on the main form?

(Records are located in the subform)

thanks in advance

GregoryHu
 
Old June 29th, 2004, 11:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If it's just a standard filter, you could either:
a) Use the Filter button that's on the standard toolbar
b) put some code into your own button such as:
Code:
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
I am a loud man with a very large hat. This means I am in charge
 
Old June 30th, 2004, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

On the button's ON CLICK event you can simply do this

Me.sfrMySuform.Filter = "[strMyField] = '" & Me.txtMyField & "'"

or

Me.sfrMySubform.Filter = "[intMyField] = 7"

or

Me.sfrMySubform.Filter = "[dtmMyField] >= #" & Me.txtMyDate & "#"

or whatever you want your field to equal.

Set the filter = "" to reset it back to all.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old July 9th, 2004, 10:26 AM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks , you helped me a lot


GregoryHu





Similar Threads
Thread Thread Starter Forum Replies Last Post
subform jeremy1048 Access 0 May 2nd, 2008 09:03 AM
Referencing a subform scandalous Access 2 March 16th, 2007 07:05 AM
Search in subform webace Access 0 June 12th, 2006 11:52 AM
Filter Subform B Based on Field in Subform A SerranoG Access VBA 3 June 18th, 2004 12:23 AM
Referring to a Subform mikericc Access 1 April 9th, 2004 04:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.