Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 December 18th, 2004, 06:39 PM
Authorized User
 
Join Date: Apr 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default form opening with where clause

When I open a form via VBA using a where clause, it opens and filters correctly, but I'm having trouble removing the filter.

I've tried Records->remove/filter sort, and the usuals without luck

Access 2K3 - ADP SQL Serv. 2K

Any ideas ?



 
Old December 19th, 2004, 02:18 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

You are using the where clause as your filters to return the records, there fore when you remove it no records will show.

Code:
Sorting:
DoCmd.GoToControl "control at which you want to sort"
DoCmd.RunCommand acCmdSortAscending ' or acCmdSortDescending

Removing filters or sorting:
DoCmd.RunCommand acCmdRemoveFilterSort
Jaime E. Maccou
 
Old December 19th, 2004, 02:23 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

In your command button you could issue the following code:

DoCmd.ShowAllRecords

This will remove the filter/sort. Or, you can do this:

Code:
Me.Filter = ""
Me.FilterOn = False
To set another filter do this:

Code:
Me.Filter = "[FieldName] = 'Criteria'"
Me.FilterOn = True
Jaime E. Maccou
 
Old December 20th, 2004, 09:07 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

When you say you want to remove the filter, are you trying to then re-open the form so that you can see all the records?

It sounds like you are passing a filter on a DoCmd statement from a button, and then once the form is opened and filtered, you want to change to viewing all the records. Is that correct? If so, you could add a button to the form that closes and re-opens in showing all the records.



mmcdonal
 
Old December 22nd, 2004, 09:16 PM
Authorized User
 
Join Date: Apr 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmcdonal, that is precisely what I need to accomplish, Hopefully Jaime's solution will achieve this, since I'd rather not open and close the form.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening 1 form from another jainin_shah9 C# 2005 5 February 18th, 2008 07:31 AM
Form Corruption / Problems with Where Clause jeremy1048 Access 7 October 22nd, 2007 09:52 AM
Opening a Form arholly Access 1 January 17th, 2007 11:59 AM
Closing a form after opening another form rosebushr Access 2 January 7th, 2006 04:34 AM
Problem using WHERE clause in opening Recordset johnman Classic ASP Databases 2 October 23rd, 2003 01:30 PM





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