Printing different reports based on criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two different invoice reports based on productID. After I have entered
what invoice number I want to see, my commandbutton should print report A if
productID is between 80 and 89, else it should print report B. Is it possible
to put this criteria to OpenReport-action or is Visual Basic needed.

Thankful for Your help!
 
Tellu,

In the Condition for the OpenReport action for Report A, you can put the
equivalent of this...
DCount("*","YourQuery","[ProductID] Between 80 And 89")>0
.... and in the Condition for the OpenReport action for Report B...
DCount("*","YourQuery","[ProductID] Between 80 And 89")=0
.... where 'YourQuery' is the name of the query that the report is based on.

If you can't see the Condition column in the macro design window, select
it from the View menu.
 
Thank you Steve, Dcount works perfect! Can you still help me a little bit?
How can I do the same thing if there' re many invoices that open at the same
time and some of them should show report A and some report B (based on the
ProductID of course). Dcount can't be used here.

Tellu
--
Thankful for Your help!


"Steve Schapel" kirjoitti:
Tellu,

In the Condition for the OpenReport action for Report A, you can put the
equivalent of this...
DCount("*","YourQuery","[ProductID] Between 80 And 89")>0
.... and in the Condition for the OpenReport action for Report B...
DCount("*","YourQuery","[ProductID] Between 80 And 89")=0
.... where 'YourQuery' is the name of the query that the report is based on.

If you can't see the Condition column in the macro design window, select
it from the View menu.

--
Steve Schapel, Microsoft Access MVP
I have two different invoice reports based on productID. After I have entered
what invoice number I want to see, my commandbutton should print report A if
productID is between 80 and 89, else it should print report B. Is it possible
to put this criteria to OpenReport-action or is Visual Basic needed.

Thankful for Your help!
 
Tellu,

I assume there could be more than one product per any given invoice?
And that you want A if *any* of the ProductID for that invoice in the
80-89 range?

If you are printing multiple invoices at once, it seems to me that you
could control this via the criteria of the query that the invoice is
based on. In other words, you could make a query that returns the
invoice numbers that contain an 80-89 Product. Then, join this query
into the existing query that the invoice is based on. In the case of
Report A, it will be a simple Inner Join on the Invoice Number (or
whatever your invoice ID is called). In the case of Report B, you would
use a Left Join, and thern with Is Null in the Criteria of the Invoice
Number field.

Sorry, difficult to be more explicit without knowing details of the
data. If you still need help with this, maybe you could post back with
the SQL view of the report's queries, that would help me to see how your
data is put together.
 
Steve,

With your help I succeeded so far that macro opens different reports for
different products. The only problem is that if either report is empty report
opens however. OpenReport's "Where" doesn't ungerstand criteria [invoiceID]
is not null. What can be done?

Tellu
 
Tellu,

Well, to be accurate, the Where Condition argument of the OpenReport
action *does* understand [InvoiceID] Is Not Null. It's just that in the
case of a report with no records returned, this condition is not
applicable - you don't have an InvoiceID that is not null... you have no
InvoiceID at all, which is a different situation altogether! No, you
will need to use the macro Condition here, to restrict the running of
the OpenReport action where there is data returned. For this, you use
DCount() function on the query that the report is based on, like this...
DCount("*","YourQuery")>0
 
Hello Steve,

I wrote once already, but I don't know where the message went? I solved the
problem with NoData event on the report, but I suppose your way ís better.
Thanks a lot again!

Tellu


--
Thankful for Your help!


"Steve Schapel" kirjoitti:
Tellu,

Well, to be accurate, the Where Condition argument of the OpenReport
action *does* understand [InvoiceID] Is Not Null. It's just that in the
case of a report with no records returned, this condition is not
applicable - you don't have an InvoiceID that is not null... you have no
InvoiceID at all, which is a different situation altogether! No, you
will need to use the macro Condition here, to restrict the running of
the OpenReport action where there is data returned. For this, you use
DCount() function on the query that the report is based on, like this...
DCount("*","YourQuery")>0

--
Steve Schapel, Microsoft Access MVP
Steve,

With your help I succeeded so far that macro opens different reports for
different products. The only problem is that if either report is empty report
opens however. OpenReport's "Where" doesn't ungerstand criteria [invoiceID]
is not null. What can be done?

Tellu
 
Back
Top