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.