Need to set default filter on form

Q

querykitty

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
 
E

Evi

See if this does it:

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

Evi
 
Q

querykitty

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.

Evi said:
See if this does it:

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

Evi
querykitty said:
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
 
E

Evi

Got it!

In the OnApply Filter event just enter the line

Cancel = True


Nothing else is needed.

Evi



querykitty said:
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.

Evi said:
See if this does it:

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

Evi
querykitty said:
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
 
Q

querykitty

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.

Evi said:
Got it!

In the OnApply Filter event just enter the line

Cancel = True


Nothing else is needed.

Evi



querykitty said:
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.

Evi said:
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
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
 
E

Evi

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


querykitty said:
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.

Evi said:
Got it!

In the OnApply Filter event just enter the line

Cancel = True


Nothing else is needed.

Evi



querykitty said:
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:

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

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top