?
Solved

Need help with Yes/No field on a report

Posted on 2014-02-21
9
Medium Priority
?
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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
 
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 2000 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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