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.


 
Hi sosed!

Count your commas. The command should look like this:

DoCmd.OpenReport "YourReport", , , "YourWhereCondition"

Or

DoCmd.OpenReport "YourReport", YourView, , "YourWhere"

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top