Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2008

Tip: Looking for answers? Try searching our database.

Need to set default filter on form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
querykitty - 22 May 2008 19:31 GMT
I have a datasheet form which opens from a Macro.  In the Macro I set a
filter.  I would like the user to be able to filter on the datasheet but only
based on my original filter criteria.  Currently what is happening is if they
click the "remove filter" button on the tool bar then it shows all records in
the table and not just the ones I originally displayed for them.  I've been
trying to use the OnApplyFilter event from the form's property box, but don't
seem to be doing something correctly.  I was trying to say:

If me.filteron = false Then ' user is removing the filter using the filter
button
me.Status = "Rev" ' my original criteriea
End If
Evi - 22 May 2008 21:05 GMT
See if this does it:

If Me.Filter = "" Then
Me.Filter = "[Status]= 'Rev'"
Me.FilterOn = True
End if

Evi
> I have a datasheet form which opens from a Macro.  In the Macro I set a
> filter.  I would like the user to be able to filter on the datasheet but only
[quoted text clipped - 8 lines]
> me.Status = "Rev" ' my original criteriea
> End If
querykitty - 22 May 2008 21:43 GMT
Unfortunately, no go.  Which event should I be doing this in, the "On Apply
Filter" event or the "On Filter" event.  I've tried them both with this
suggestion without success.

> See if this does it:
>
[quoted text clipped - 21 lines]
> > me.Status = "Rev" ' my original criteriea
> > End If
Evi - 22 May 2008 22:49 GMT
Got it!

In the OnApply Filter event just enter the line

Cancel = True

Nothing else is needed.

Evi

> Unfortunately, no go.  Which event should I be doing this in, the "On Apply
> Filter" event or the "On Filter" event.  I've tried them both with this
[quoted text clipped - 25 lines]
> > > me.Status = "Rev" ' my original criteriea
> > > End If
querykitty - 23 May 2008 15:27 GMT
No this just stopped the form from filtering altogether.  

My issues is that I open the form with a filter, but I want to allow the
user to do further filtering, but based on my original filter.  And this
works when they apply the filter, but when the remove the filter it removes
my orginal filter as well, so I am trying to reapply the "default" filter on
the remove filter event.

> Got it!
>
[quoted text clipped - 42 lines]
> > > > me.Status = "Rev" ' my original criteriea
> > > > End If
Evi - 23 May 2008 22:08 GMT
You can still filter by code but not via  the toolbar.

You can supply your own (controlled) remove filter button which begins each
operation with
Me.FilterOn = False
(to remove the previous filter)
followed by
Me.Filter = "[Status]= 'Rev'"
Me.FilterOn = True

If you are supplying the usual tools for custom filtering (textboxes,
combos, buttons etc) you could concatenate your criteria onto the beginning
of theirs in the AfterUpdate and Onclick events

eg the user has typed text into a text box named txtCriteria and pressed a
button

Dim MyFilt As String

MyFilt =  "[Status]= 'Rev' AND "
Me.Filter = MyFilt & Me.txtCriteria
Me.FilterOn = True

Evi

> No this just stopped the form from filtering altogether.
>
[quoted text clipped - 50 lines]
> > > > > me.Status = "Rev" ' my original criteriea
> > > > > End If
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20.   Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20.   Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20.   Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20.   Every effort will be
made to respond to messages, but please be patient.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.