Solved Reformulate an expression with multiple criteria (Numbers and dates)

Falcon88

Registered User.
Local time
Today, 23:50
Joined
Nov 4, 2014
Messages
309
hii al dears

i have this expression :
Code:
PersonA: CLng(nz(Dcount("OrderID";"Q105";"InsurCmpName=13" & " AND [OrderDate]>= #" [FirstDayVal] & "# AND  [OrderDate] <=" # [LastDayVal]);0))

Can you hlep me to correct this expression ?
 
What is it supposed to do? I think DCount() should either return a zero (0) or a higher number, so Nz() is probably not necessary.
 
Dcount("OrderID";"Q105";"InsurCmpName=13 AND [OrderDate]>= #" & [FirstDayVal] & "# AND [OrderDate] <= #" & [LastDayVal] & "#")
 
Dcount("OrderID";"Q105";"InsurCmpName=13 AND [OrderDate]>= #" & [FirstDayVal] & "# AND [OrderDate] <= #" & [LastDayVal] & "#")
it gives me wrong results
what the correct expression?
 
Might want to put the criteria into a string variable, debug.print it until you get it correct, then use that in the function.
If you cannot get it correct, then you can post the output back here.
 
Wrong in what way? I think it's a valid expression now, so check your values.
 
I dare say your dates are in the wrong format?
 
Try wrapping in format.
"OrderID";"Q105";"InsurCmpName=13 AND [OrderDate]>= #" & Format([FirstDayVal],'MM/DD/YYYY') & "# AND [OrderDate] <= #" & format([LastDayVal],'MM/DD/YYYY') & "#"
 
Try wrapping in format.
"OrderID";"Q105";"InsurCmpName=13 AND [OrderDate]>= #" & Format([FirstDayVal],'MM/DD/YYYY') & "# AND [OrderDate] <= #" & format([LastDayVal],'MM/DD/YYYY') & "#"
very thanks , it sloved
 
In fact you have come across this issue before and used a format, defined as a constant?

 
In fact you have come across this issue before and used a format, defined as a constant?

Yes, I forgot, it was more than 7 years ago.

Greetings to you
 
Yes, I forgot, it was more than 7 years ago.

Greetings to you
Well I have a pretty bad memory these days :( , but once the date issue bit me, I have always remembered it. :)
 

Users who are viewing this thread

Back
Top Bottom