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 / March 2005

Tip: Looking for answers? Try searching our database.

Applyfilter works, sometimes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leif - 10 Mar 2005 18:07 GMT
I've built a query form that returns a string I want to apply to the main
form.  Sometimes that works fine, other times I get the message "You can't
use the ApplyFilter action on this window".  To try to be sure I'm on the
correct window I do a docmd.SelectObject command first, but that does not
help.  My code looks like the following:

   If qFilter <> "" Then
       DoCmd.SelectObject acForm, "Project"
       DoCmd.ApplyFilter , qFilter
   End If

where qFilter is the filter string and "Project" is the name of form I want
to apply the filter to.  As a work around I tried to set qFilter to the form
filter property, however, this only works if the string is not too big.  I
need the 32K character length that apply filter gives me.

In as case where it works the string is:
"ProjectID IN (597)"

In a case where it did not work the string is:
"ProjectID IN (4)"

This is a hard one.  Thanks for your help.
Rob Oldfield - 10 Mar 2005 22:35 GMT
It's something to do with data being out of date when you try to run the
code.  Try adding in a requery...

If qFilter <> "" Then
   me.requery
   DoCmd.SelectObject acForm, "Project"
   DoCmd.ApplyFilter , qFilter
End If

...and if that doesn't work, then what context is this being run in?  Which
event?  What is the form based on: a straight table, a query of a single
table, or a query of multiple tables?

> I've built a query form that returns a string I want to apply to the main
> form.  Sometimes that works fine, other times I get the message "You can't
[quoted text clipped - 19 lines]
>
> This is a hard one.  Thanks for your help.
Leif - 11 Mar 2005 02:51 GMT
Rob,

Thanks for your reply.  I found the problem, and it does not seem to relate
to the error message I got.  The recordsource I had did not include the items
I was using in my filtering (which is similar to what you suggest with the
requery).

Don't you think it is odd that using applyfilter you can have a string up to
32K, but with the filter property the size is much more limited?  My query
form sets a string variable for applyfilter to use.  I found that if I try to
set the filter property of the form instead that at 1800 characters it fails.
I don't know what is the actual limit.

Thanks,
Leif

> It's something to do with data being out of date when you try to run the
> code.  Try adding in a requery...
[quoted text clipped - 34 lines]
> >
> > This is a hard one.  Thanks for your help.
Rob Oldfield - 11 Mar 2005 08:17 GMT
Glad to hear it.

Yes... the filter length thing is a bit hard to explain.  There is an
alternative method... write the values that you wish to filter on into a
temporary table, and then use that table in the record source of the form to
limit it to just those records with a match.

> Rob,
>
[quoted text clipped - 50 lines]
> > >
> > > This is a hard one.  Thanks for your help.
 
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.