Solved

Need help with Yes/No field on a report

Posted on 2014-02-21
9
199 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

747 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

13 Experts available now in Live!

Get 1:1 Help Now