Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a report with long WHERE condition

Status
Not open for further replies.

sosed

Programmer
Feb 1, 2002
5
IL
Hi!

I've been trying to invoke a report with a condition
based on the user's choices in a multi-select
listbox on a form.

The listbox contains names of customers (a few
hundreds), and the report shows their details.
Now, I've written an event procedure for a command
button, which builds the proper WHERE clause
for the report's query and then opens the report
using DoCmd.OpenReport function with the constructed
where condition (the last argument).
The problem is that when I choose (too?) many entries in the listbox, the OpenReport function
generates the following error:

Error number: 7769.
The filter operation was canceled. The filter would be
too long.


I consulted Help, and it says that from VBA I can
set the where condition argument to be maximum
~32000 characters. My condition is much smaller than that
and it still wouldn't work. Why does the error message
says something about filter. I'm not trying to FILTER
the query, I'm trying to apply a WHERE condition to it.

Any ideas as to why this doesn't work?
How I can use a very long WHERE condition in a report's
query (using DoCmd.OpenReport)?
Has anyone encountered this kind of problem?

Thanks,
sosed.


 
Are you sure you're putting the where condition in the proper argument of the openreport command? The arguments are (ReportName, view, filter, where condition).

So you're command should look like this:
docmd.openreport "ReportName",acviewnormal , , Criteria

not like this:

docmd.openreport "ReportName", acviewnormal, Criteria Maq B-)
<insert witty signature here>
 
The WHERE clause is a filter on the data and it is typically called a filter in Access.

If you don't get an answer, there are work arounds but the solution would depend on the backend database. Are you using Access 2000 or Sql Server as the database?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top