Solved

Need help with Yes/No field on a report

Posted on 2014-02-21
9
205 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

717 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