Aug 20 2022 10:21 AM
Experts,
I am using IIF to evaluate whether or not a date [InvDueDate] is between the criteria below. It is not evaluating correctly in all cases since it returns "Payment is Pending" even when [InvDueDate] is outside the criteria. I seem to remember that IIF is not the best way to do this. Maybe there is a better way to write the expression (DateSerial or CDate?).
Any help is appreciated.
the below is in a text box on a report.
=IIf([txtInvDueDate] Between Date() And Date()+20,"Payment is Pending","")
I have also tried the below using DateAdd but the results are the same:
=IIf([txtInvDueDate] Between Date() And DateAdd("d",20,Date()),"Payment is Pending","")
Aug 20 2022 10:36 AM
Aug 20 2022 11:02 AM
HI George, I cant say for sure if it has something to do with as you describe above. I looked at it further and I forgot I am using a Union and on one of the queries I put "" as InvDueDate for the column since the field InvDueDate is not in that table. I think its termed "dummy" column.
Below are the columns in the Union. I am only taking a snippet of the entire code. I am not sure if its advisable to use "" as I did below but I think I must since the field is not in the table.
this is the first query in the union:
, "" AS InvDueDate,
this is the first query in the union:
,tblFXRollsChild.InvDueDate,
The correct invoice date is being returned by the Union though so to me using "" is not the issue (but it could be...see far below DateValue part) since its referring to the correct invoice date.
I dont have a format placed on the field. I do nto see a time being added to the date in the datasheet display so to me it also doesnt seem likely its due to the time as you touched on above.
Using DateValue()
I might be on to something.
=IIf(DateValue([txtInvDueDate]) Between Date() And Date()+20,"Payment is Pending","")
It returned #Type on some of the records.
It ight have something to do with me assigning "" to the InvDueDate?
What else can I do than assign a "" for a dummy column?
Aug 20 2022 12:20 PM
Aug 20 2022 01:49 PM
Aug 21 2022 06:57 AM
SolutionAug 21 2022 08:20 AM
Aug 21 2022 08:26 AM
Aug 21 2022 11:58 PM
Aug 22 2022 05:09 AM
Aug 21 2022 06:57 AM
Solution