Solved

Need help with Yes/No field on a report

Posted on 2014-02-21
9
202 Views
Last Modified: 2014-02-22
I have a report with a field named txtOnTime which gets filled with a Y or an N which comes from a query field that reads:

OnTime: IIf([MaxOfDateShpd]<=fnMax([Ack_Date],[ReschDate]),"Y","N")

This has been working fine until I add this to the end of it:

Or IIf([ReschDate]="","Y","N")

So I end up with:

OnTime: IIf([MaxOfDateShpd]<=fnMax([Ack_Date],[ReschDate]),"Y","N") Or IIf([ReschDate]="","Y","N")

Then all records end up with a -1 in them.

Here is the code in the fnMax module someone had helped me with some time ago.
Maybe it just has to be altered but I don't know how to do it.

Public Function fnMax(ParamArray ValList() As Variant) As Variant

   Dim intLoop As Integer
   Dim myVal As Variant
   
   For intLoop = LBound(ValList) To UBound(ValList)
      If Not IsNull(ValList(intLoop)) Then
         If IsEmpty(myVal) Then
            myVal = ValList(intLoop)
         ElseIf ValList(intLoop) > myVal Then
            myVal = ValList(intLoop)
         End If
      End If
   Next
   fnMax = myVal
   
End Function

Open in new window

0
Comment
Question by:SteveL13
  • 4
  • 4
9 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878081
Revise your formula to this:
OnTime: IIf(([MaxOfDateShpd]<=fnMax([Ack_Date],[ReschDate])) OR ([ReschDate] Is Null),"Y","N")

Open in new window

Ron
0
 

Author Comment

by:SteveL13
ID: 39878102
Didn't work.  Now I'm getting all "Y"'s
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878118
Are all the data types of your fields here set to TEXT or DATE?
0
 

Author Comment

by:SteveL13
ID: 39878134
In this:

OnTime: IIf(([MaxOfDateShpd]<=fnMax([Ack_Date],[ReschDate])) OR ([ReschDate] Is Null),"Y","N")

All are date.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878149
So if there is no date given in ReschDate, you want it to be marked as OnTime, right? If that is the case, I don't see anything wrong with the formula I posted.  Could you provide some data for each of these fields where the results come up as "Y"?
0
 

Author Comment

by:SteveL13
ID: 39878180
The data is very confidential but here is a screen shot (attached).

Using this example,

Anywhere Last Date Shipped > Ack Date it should be an "N" in the On Time column.

Anywhere Last Date Shipped <= Ack Date it should be an "Y" in the On Time column.

Anywhere the is a date in the ReschDate it should be an "N" in the On Time column

Does this help?
sample.jpg
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
ID: 39878220
In that case your formula should be:
OnTime: IIf([ReschDate] Is Not Null Or [MaxOfDateShpd]>[Ack_Date], "N", "Y")

Open in new window

0
 

Author Closing Comment

by:SteveL13
ID: 39879250
Thank you very much.

And mbizup... thank you for the information.  

All is very much appreciated.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now