Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2004, 04:44 AM
Authorized User
 
Join Date: Dec 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested If

I have to pick up the latest of the actions out of 5 in every record in a table/query. The actions are available as Text in 5 different fields and the latest out of say PT, PT1, PT2, PT3 and PT4 has to be selected for a report. In layman's language, the function will go like this...If PT4 is Null, PT3; If PT3 is Null, PT2; If PT2 is Null, PT1;Otherwise PT
Do I use a Nested If function or is there any other alternative?
Thanks for your time and patience
Rao

 
Old December 7th, 2004, 11:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

No IF needed. You can do this

DesiredValue = Nz(PT4,Nz(PT3,Nz(PT2,Nz(PT1,Nz(PT,0)))))

Note that I even went further and assumed zero if PT is null.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old December 7th, 2004, 11:02 PM
Authorized User
 
Join Date: Dec 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quite a neat solution
Thanks a lot
Can we now improve this a bit? like if the user mixes up while entering, by leaving one field blank and entering the other one and entering the previous one later (like leaving PT1 blank first and entering PT2 and entering PT1 later), then the whole solution will be wrong. Can we relate this to the date of entry ?
Thanks for your time and patience
Rao

 
Old December 8th, 2004, 08:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

I don't understand why the solution would be wrong. You said that there is a hierarchy of what order the numbers go in from PT4 down to PT, with some of them being null sometimes. The solution I gave you works for no matter what order the person enters them given your hierarchy.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old December 10th, 2004, 12:39 AM
Authorized User
 
Join Date: Dec 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is possible because the user may enter first say PT1, then the next one he enters in PT3 instead of PT2 and then the third one realises that PT2 is vacant and fills up the field. So, chronologically in this case, PT2 is after PT3.
If the date is added to the entry by having a date of entry field, then it would be possible to track the latest (chronologically) entry.
I hope I have clarified it properly
Thanks for your time and patience
Rao






Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested query deb1980 ASP.NET 2.0 Basics 2 April 10th, 2007 04:38 AM
nested for hastikeyvan Classic ASP Professional 1 July 27th, 2006 06:28 PM
nested for-each sassymonix XSLT 6 May 16th, 2006 06:47 AM
Nested If Statement KCTin Visual Basic 2005 Basics 3 December 28th, 2005 01:53 PM
Nested Do Until Loop goels Access VBA 2 September 30th, 2004 08:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.