Report Criteria

G

Guest

I have a report whcih contains customer Names, on report Header and details
Like Date, order number, units, rate, qty etc. in detail section when I open
the report a popup form appears and ask for StartDate, EndDate & have a
Combo box contains all customers names to be enter, I want that if user not
select any customer it shows data from all customers.
 
A

Allen Browne

It is possible to craft the WHERE clause of the source query so that it
returns all records if the combo is left blank. It's messy and inefficient,
but it is possible.

An alternative approach is to open the form first, and then click a button
on the form to open the report after you enter the criteria. You leave the
criteria out of the report's query. Instead, use the Click event procedure
for the button to build the WhereCondition string to use in OpenReport.

The code just ignores the combo if it is blank, e.g.:
If Not IsNull(me.Combo1) Then ...

If this approach is new, see Method 2 in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
 
G

Guest

Sir if is there any query altertion please tell me bcz I just not wnat to use
an event procedure.
 
A

Allen Browne

Build the WHERE clause of the query like this:

WHERE (([Forms]![Form1]![Combo1] Is Null)
OR (CustomerID = [Forms]![Form1]![Combo1] Is Null))
AND (Date1 Between [Forms]![Form1]![txtFrom]
And [Forms]![Form1]![txtTo])

This works because:
[Forms]![Form1]![Combo1] Is Null
is a True expression for all records if the combo is null.
 

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

Similar Threads

Report Critera 3
Parameter Query 2
Report help 8
Date Range Query. Criteria based in a table. 4
MS Office cant find object "DoCmd" 27
Report Help 1
One record per page 1
Variable VAT by product and customer 2

Top