|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
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.
-- Steve Schapel, Microsoft Access MVP
Tellu wrote:
[Quoted Text] > 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!
|
|
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:
[Quoted Text] > 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 > > Tellu wrote: > > 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 Schapel, Microsoft Access MVP
Tellu wrote:
[Quoted Text] > 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
|
|
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 -- Thankful for Your help!
"Steve Schapel" kirjoitti:
[Quoted Text] > 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 Schapel, Microsoft Access MVP > > Tellu wrote: > > 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 >
|
|
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
Tellu wrote:
[Quoted Text] > 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
|
|
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:
[Quoted Text] > 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 > > Tellu wrote: > > 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,
No, the NoData event of the report is a fine way to handle it.
-- Steve Schapel, Microsoft Access MVP
Tellu wrote:
[Quoted Text] > 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 > >
|
|
|