![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
=91 , " & _ " Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " |
#2
| |||
| |||
|
|
I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ * * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ * * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60" &_ * * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ * * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90" &_ * * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ * * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 * * * * * * * * * * * WHERE Now()-[DPATDAT.Inv_Date]>=91 * * * * * * * * * * * * * * * * *, " & _ * * * * * " * * * Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash |
#3
| |||
| |||
|
|
I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? Is DPATDAT.Inv_Date a regular date field (mm/dd/yyyy) or does it also |
|
strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 WHERE Now()-[DPATDAT.Inv_Date] =91 , " & _ " Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash |
#4
| |||
| |||
|
| WHERE Now()-[DPATDAT.Inv_Date] >= 0 " &_ |
#5
| |||
| |||
|
|
I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 WHERE Now()-[DPATDAT.Inv_Date] =91 , " & _ " Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " |
#6
| |||
| |||
|
|
prakashwadhw... (AT) gmail (DOT) com wrote: I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? Is DPATDAT.Inv_Date a regular date field (mm/dd/yyyy) or does it also contain hh:mm:ss?. *Ex: ? now() - date * 0.328576388885267 ? now() - date-1 * -0.670405092590954 ? date() - date-1 * -1 Subracting where both are date() instead of a now() will return a whole number. Filtering like you have done might retrieve more accurate results if you used Dsum(). *Ex: strSQL2 = "select DSum("DEBIT","DPATDAT","InvDate - date() >= 0 and InvDate - date() <= 30) AS SumOf0to30 Instead of using Dsum, maybe Esum. *http://allenbrowne.com/ser-66.html strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ * * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ * * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ * * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ * * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ * * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ * * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 * * * * * * * * * * * WHERE Now()-[DPATDAT.Inv_Date] =91 * * * * * * * * * * * * * * * * *, " & _ * * * * * " * * * Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash |
#7
| |||
| |||
|
|
On Apr 15, 7:04 pm, Salad <o... (AT) vinegar (DOT) com> wrote: prakashwadhw... (AT) gmail (DOT) com wrote: I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? Is DPATDAT.Inv_Date a regular date field (mm/dd/yyyy) or does it also contain hh:mm:ss?. Ex: ? now() - date 0.328576388885267 ? now() - date-1 -0.670405092590954 ? date() - date-1 -1 Subracting where both are date() instead of a now() will return a whole number. Filtering like you have done might retrieve more accurate results if you used Dsum(). Ex: strSQL2 = "select DSum("DEBIT","DPATDAT","InvDate - date() >= 0 and InvDate - date() <= 30) AS SumOf0to30 Instead of using Dsum, maybe Esum. http://allenbrowne.com/ser-66.html strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 WHERE Now()-[DPATDAT.Inv_Date] =91 , " & _ " Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash Hi Salad ... thx for replying. I'm sorry - you are right. DPATDAT.Inv_Date IS a regular date field and so you've pointed out my mistake correctly. Could you please tell me why the Dsum would be better to use than the SUM in the select statement ? |
|
In the meanwhile I'll try correcting my syntax & get back if there's any further problems. Best Rgds, Prakash. |
#8
| |||
| |||
|
|
prakashwadhw... (AT) gmail (DOT) com wrote: On Apr 15, 7:04 pm, Salad <o... (AT) vinegar (DOT) com> wrote: prakashwadhw... (AT) gmail (DOT) com wrote: I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? Is DPATDAT.Inv_Date a regular date field (mm/dd/yyyy) or does it also contain hh:mm:ss?. *Ex: ? now() - date *0.328576388885267 ? now() - date-1 *-0.670405092590954 ? date() - date-1 *-1 Subracting where both are date() instead of a now() will return a whole number. Filtering like you have done might retrieve more accurate results if you used Dsum(). *Ex: strSQL2 = "select DSum("DEBIT","DPATDAT","InvDate - date() >= 0 and InvDate - date() <= 30) AS SumOf0to30 Instead of using Dsum, maybe Esum. *http://allenbrowne.com/ser-66.html strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ * * * * *" * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ * * * * *" * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ * * * * *" * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ * * * * *" * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ * * * * *" * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ * * * * *" * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 * * * * * * * * * * *WHERE Now()-[DPATDAT.Inv_Date] =91 * * * * * * * * * * * * * * * **, " & _ * * * * *" * * * Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash Hi Salad ... thx for replying. I'm sorry - you are right. *DPATDAT.Inv_Date IS a regular date field and so you've pointed out my mistake correctly. Could you please tell me why the Dsum would be better to use than the SUM in the select statement ? Because you can associate a filter to the Suming process. *Maybe you are using something else besides an MDB backend and can use the syntax like above. In the meanwhile I'll try correcting my syntax & get back if there's any further problems. Best Rgds, Prakash. |
#9
| |||
| |||
|
|
On Apr 15, 10:02 pm, Salad <o... (AT) vinegar (DOT) com> wrote: prakashwadhw... (AT) gmail (DOT) com wrote: On Apr 15, 7:04 pm, Salad <o... (AT) vinegar (DOT) com> wrote: prakashwadhw... (AT) gmail (DOT) com wrote: I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? Is DPATDAT.Inv_Date a regular date field (mm/dd/yyyy) or does it also contain hh:mm:ss?. Ex: ? now() - date 0.328576388885267 ? now() - date-1 -0.670405092590954 ? date() - date-1 -1 Subracting where both are date() instead of a now() will return a whole number. Filtering like you have done might retrieve more accurate results if you used Dsum(). Ex: strSQL2 = "select DSum("DEBIT","DPATDAT","InvDate - date() >= 0 and InvDate - date() <= 30) AS SumOf0to30 Instead of using Dsum, maybe Esum. http://allenbrowne.com/ser-66.html strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ " WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ " Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 WHERE Now()-[DPATDAT.Inv_Date] =91 , " & _ " Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash Hi Salad ... thx for replying. I'm sorry - you are right. DPATDAT.Inv_Date IS a regular date field and so you've pointed out my mistake correctly. Could you please tell me why the Dsum would be better to use than the SUM in the select statement ? Because you can associate a filter to the Suming process. Maybe you are using something else besides an MDB backend and can use the syntax like above. In the meanwhile I'll try correcting my syntax & get back if there's any further problems. Best Rgds, Prakash. Hi Salad, I have tried it but somehow there seems to be some problem in the filter. No syntax error ... just that no values are being picked up from the table. Here is my statement: SumOf0to30 = Nz(DSum("[DEBIT]", "DPATDAT", "[code] = " & Me.txt_Code & " AND [Inv_Date] - date() >= 0 AND [Inv_Date] - date() <= 30 ")) I have singled out the [code] = " & Me.txt_Code part and that is perfect. It's the date part which is creating a problem. Now, I must say my date format everywhere is dd/mm/yy. Could that be creating a problem ? I'd greatly appreciate any help. Thx again to everyone, Prakash. |
#10
| |||
| |||
|
|
prakashwadhw... (AT) gmail (DOT) com wrote: On Apr 15, 10:02 pm, Salad <o... (AT) vinegar (DOT) com> wrote: prakashwadhw... (AT) gmail (DOT) com wrote: On Apr 15, 7:04 pm, Salad <o... (AT) vinegar (DOT) com> wrote: prakashwadhw... (AT) gmail (DOT) com wrote: I'm trying to generate an Age Analysis Report where the foll SQL statement will executed be in a loop for each customer. Can someone please correct my SQL code and/or provide any ideas ? Is DPATDAT.Inv_Date a regular date field (mm/dd/yyyy) or does it also contain hh:mm:ss?. *Ex: ? now() - date 0.328576388885267 ? now() - date-1 -0.670405092590954 ? date() - date-1 -1 Subracting where both are date() instead of a now() will return a whole number. Filtering like you have done might retrieve more accurate results if you used Dsum(). *Ex: strSQL2 = "select DSum("DEBIT","DPATDAT","InvDate - date() >= 0 and InvDate - date() <= 30) AS SumOf0to30 Instead of using Dsum, maybe Esum. *http://allenbrowne.com/ser-66.html strSQL2 = "select Sum(nz(DPATDAT.[DEBIT])) AS SumOf0to30 " &_ * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=0 and Now()- [DPATDAT.Inv_Date] <=30, " & _ * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf31to60 " &_ * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=31 and Now()- [DPATDAT.Inv_Date] <=60, " & _ * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOf61to90 " &_ * * * * " * * * * * WHERE Now()-[DPATDAT.Inv_Date] >=61 and Now()- [DPATDAT.Inv_Date] <=90, " & _ * * * * " * * * Sum(nz(DPATDAT.[DEBIT])) AS SumOfgt90 * * * * * * * * * * WHERE Now()-[DPATDAT.Inv_Date] =91 * * * * * * * * * * * * * * * * *, " & _ * * * * " * * * Sum(nz(DPATDAT.[CREDIT])) AS SumOfCredits " Thx & best Rgds,\Prakash Hi Salad ... thx for replying. I'm sorry - you are right. *DPATDAT.Inv_Date IS a regular date field and so you've pointed out my mistake correctly. Could you please tell me why the Dsum would be better to use than the SUM in the select statement ? Because you can associate a filter to the Suming process. *Maybe you are using something else besides an MDB backend and can use the syntax like above. In the meanwhile I'll try correcting my syntax & get back if there's any further problems. Best Rgds, Prakash. Hi Salad, I have tried it but somehow there seems to be some problem in the filter. No syntax error ... just that no values are being picked up from the table. Here is my statement: SumOf0to30 = Nz(DSum("[DEBIT]", "DPATDAT", "[code] = " & Me.txt_Code & " AND [Inv_Date] - date() >= *0 *AND [Inv_Date] - date() <= *30 ")) I have singled out the *[code] = " & Me.txt_Code *part and that is perfect. It's the date part which is creating a problem. Now, I must say my date format everywhere is dd/mm/yy. Could that be creating a problem ? I'd greatly appreciate any help. Thx again to everyone, Prakash. If you use NZ, you should supply two values. *Ex: * * * * ? IIF(TrueValue,1,0) I don't see your false value in the example above. *Ex: * * * * ? NZ(Dsum("FieldName","TableName","ID = 1"),0) |
![]() |
| Thread Tools | |
| Display Modes | |
| |