473,471 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Return text with IIf function

41 New Member
Hello,

I have Four fields:

[Starting Date]
[Ending Date]
[Time Extension]
[Maintenance Period]

All are on a date format.

I want to input a text on a text box field doing the following:

1) If today’s date < [Starting Date], then return “STARTING”
2) If [Starting Date] < today’s date < [Ending Date] then return “ONGOING”
3) If [Starting Date] < today’s date < [Time Extension] then return “ONGOING”
4) If [Time Extension] is Null then if [Ending Date] < today’s date < [Maintenance Period] then return “MAINTENANCE”
5) If [Time Extension] is not Null then if [Ending Date] < today’s date < [Maintenance Period] then return “MAINTENANCE”
6) If today’s date > [Maintenance Period], then return “COMPLETION”

Later, I will want the message “COMPLETED” to appear, when the user will have ticked a checkbox confirming the completion.

Going step by step with the Expression builder, I have built so far this:

Expand|Select|Wrap|Line Numbers
  1. =IIf(Date()<[Start Date],"Starting",IIf(Date()>[Start Date] And Date()<[Ending Date],"Ongoing",IIf(Date()>[Start Date] And Date()<[Time Extention],"Ongoing",IIf([Time Extention]=Null,IIf(Date()<[Maintenance Period] And Date()>[Ending Date],"Maintenance"),IIf(Date()<[Maintenance Period] And Date()>[Time Extention],"Maintenance")))))
It works fine with 1), 2), 3), 5), but to my surprise it did not work with 4).

Regarding 6), I did not go across it yet as I did not resolve the problem for 4).

If anyone can help…

Thanking you in advance,

G.
Jan 10 '07 #1
39 4257
NeoPa
32,556 Recognized Expert Moderator MVP
You don't don't say what you'd like to see if any of the dates are equal to today.
You don't say whether any of the stored date fields contain time elements with the date.
Otherwise, I think this is a reasonable straightforward question and I would expect an answer shortly.
If you haven't got anything by tomorrow, bump the thread and we'll see what we can do for you.
Jan 10 '07 #2
Gari
41 New Member
You don't don't say what you'd like to see if any of the dates are equal to today.
That is a good remark and actually it did not come to my mind. My database is for following up projects that typically will run over months. So if any of the dates are equal to today, I think I can just go along with replacing '<' by '<='.

You don't say whether any of the stored date fields contain time elements with the date.
There are no time elements in the date fields. Only dates on a dd/mm/yyyy format.

Otherwise, I think this is a reasonable straightforward question and I would expect an answer shortly.
If you haven't got anything by tomorrow, bump the thread and we'll see what we can do for you.
Thank you for your help.

Best regards,

G.
Jan 10 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. =IIf(Date()<=[Start Date],"Starting",
  2. IIf(Date()>[Start Date] And Date()<[Ending Date],"Ongoing",
  3. IIf(Date()>[Start Date] And Date()<[Time Extention],"Ongoing",
  4. IIf(IsNull([Time Extention]),
  5.    IIf(Date()>[Ending Date] And Date()<[Maintenance Period],"Maintenance",
  6. What do you return if false?),
  7.    IIf(Date()>[Time Extention] And Date()<[Maintenance Period],"Maintenance") 
  8. ' In No 5 you use [Ending Date] not [Time Extension]
  9. ))))
Jan 12 '07 #4
NeoPa
32,556 Recognized Expert Moderator MVP
Gari,
You need to look at your question a little more.
I'm assuming that your requirements are better expressed as (Please notice where I have included & omitted the '='s in my version.) :
I have four Date fields (no time elements) :
  • [Starting Date]
  • [Ending Date]
  • [Time Extension]
  • [Maintenance Period]
All must contain values except [Time Extension] which may be empty. Otherwise the dates are in progressive order.
I have a control which needs to show a string determined by the following logic :
  1. Treat [Time Extension] as [Ending Date] if it is not entered.
  2. If today < [Starting Date], then return "STARTING"
  3. Otherwise if today <= [Time Extension] then return "ONGOING"
  4. Otherwise if today <= [Maintenance Period] then return "MAINTENANCE"
  5. Otherwise (today must be > [Maintenance Period]) return "COMPLETION"
Please can you confirm that this is correct and not a wrong guess.
Jan 12 '07 #5
Gari
41 New Member
Dear both,

Thank you very much for your remarks. Thanks to them, I have built the following line of code:

Expand|Select|Wrap|Line Numbers
  1. =IIf(Date()<=[Start Date],"Starting",
  2. IIf(Date()>[Start Date] And Date()<= [Ending Date],"Ongoing",
  3. IIf(Date()>[Start Date] And Date()<= [Time Extention],"Ongoing",
  4. IIf(IsNull([Time Extention]),
  5. IIf(Date()>[Ending Date] And Date()<= [Maintenance Period],"Maintenance","Completion"),
  6. IIf(Date()>[Time Extention] And Date()<=[Maintenance Period],"Maintenance","Completion")))))
From what I have tested, it seems to work correctly. I think it is a good assumption that:
If Date() is >=[Start Date]
And If Date()>=[Ending Date] Or If Date()>=[Time Extention]
And If Date()>=[Maintenance Period]
Then the project is obviously completed and the formula should return "Completion".

Regarding the Checkbox thing (I did not yet set up this option), I think that in the code, instead of "Completion", I will put a line as follows:

Expand|Select|Wrap|Line Numbers
  1. IIf([Checkbox]=True,"Completed","Completion")
Thank you for your feedback.

Best regards,

G.
Jan 13 '07 #6
NeoPa
32,556 Recognized Expert Moderator MVP
Gari,
I await a response to my last post.

Your code may work but could do with a lot of tidying up (redundant code will only confuse you later on). Unfortunately, to do this properly I need confirmation of what you're actually asking.
-Adrian.
Jan 13 '07 #7
NeoPa
32,556 Recognized Expert Moderator MVP
Alternatively, if you're not interested, please let me know anyway - just a courtesy note.
Jan 13 '07 #8
Gari
41 New Member
Dear NeoPa (or Adrian ??),

Sorry to not have answered your post directly.

Your assumption is right : that is my requirement.

I wanted actually to test your sequence but I was confused by the way of writing line 1 (Treat [Time Extension] as [Ending Date] if it is not entered) (I am quite new in programming), so I came back to a code nearer to the one proposed by mmccarthy.

But as I am always eager to learn, I am greatly interested by your feedback.

Thank you and best regards.

G.
Jan 14 '07 #9
NeoPa
32,556 Recognized Expert Moderator MVP
Gari,
You can refer to me as either. My real name is public knowledge on this site now so ...
My reasoning for that line was to try to clarify the underlying logic of the request before moving on to a solution. Rather than complicated Ifs & Elses when refering to the [Time Extension] & [Ending Date] fields, I wanted to see them as a single entity where [Ending Date] is the original planned end date of the project but allowances can be made where necessary to extend this, giving [Time Extension]. For the purposes of your code (logic) however, Whenever we compare [Time Extension], we should always use [Ending Date] if [Time Extension] is not entered.
That's a more longwinded way of saying it but hopefully clearer.

The code proposed by Mary, a top contributor in this forum, is absolutely correct in that it matches your question directly. However, I think a tidying up of the question can produce simpler (easier to understand) code.
I will go off now and try to produce something a little more direct. It will work on the reliable assumption that previous lines already test for less than the value.
Jan 14 '07 #10
NeoPa
32,556 Recognized Expert Moderator MVP
The following code should be included as a single line.
I'm breaking it up to make it easier to read on here.
Expand|Select|Wrap|Line Numbers
  1. =IIf(Date()<=Nz([Time Extension],[Ending Date]),
  2. IIf(Date()<[Starting Date],"STARTING","ONGOING"),
  3. IIf(Date()<=[Maintenance Period],"MAINTENANCE","COMPLETION"))
NB. The < & <= are important and currently in the correct places.
Jan 14 '07 #11
Gari
41 New Member
Hello NeoPa,

I have tried your code but it did not work properly: I am getting an #Error message when I have no [Time Extension] date entered.

Is there something I should configure first?? I am using Access 2002 in case the info is needed.

Best regards,

G.
Jan 15 '07 #12
NeoPa
32,556 Recognized Expert Moderator MVP
Gari,
Can you let me have the setting of the Required property for the [Time Extension] field as set up in your table please (I wouldn't exepct an error there).
Also the full error message might help too - to give me somewhere to start looking.
Also, as an aside, can you follow the logic of the code ok? It's important that you understand what's in your database for future changes or use whatever.
Jan 15 '07 #13
Gari
41 New Member
Hello NeoPa,

The Required field is set to "No", as for the other dates.

There is no full error message: when the field [Time Extension] is empty, it simply returns back "#Error" in the text box.

And for the aside: Yes, I understood the logic of the code ^^.

Please do not hesitate to revert back to me should you need more information.

Best regards,

G.
Jan 15 '07 #14
NeoPa
32,556 Recognized Expert Moderator MVP
1. These fields (below), are they TextBoxes on your form too?
[Starting Date]
[Ending Date]
[Time Extension]
[Maintenance Period]

2. Can you post here the exact code you are using which returns #Error. No CRs or LFs, just the code exactly as you have it in your TextBox control.

3. Does it only result in #Error when the [Time Extension] field is empty?
Jan 15 '07 #15
Gari
41 New Member
1. These fields (below), are they TextBoxes on your form too?
[Starting Date]
[Ending Date]
[Time Extension]
[Maintenance Period]
They are all TextBoxes and they all have the same settings

2. Can you post here the exact code you are using which returns #Error. No CRs or LFs, just the code exactly as you have it in your TextBox control.
The code is as follows

Expand|Select|Wrap|Line Numbers
  1. =IIf(Date()<=Nz([Time Extension],[Ending Date]),IIf(Date()<[Start Date],"STARTING","ONGOING"),IIf(Date()<=[Maintenance Period],"MAINTENANCE","COMPLETION"))
3. Does it only result in #Error when the [Time Extension] field is empty?
Yes, only


I was wondering if the Nz() function was appropriate. From what I read in Ms Access help, it is used only to return "0" if the related field is empty. Is it true or I am mistaken ?
Jan 16 '07 #16
NeoPa
32,556 Recognized Expert Moderator MVP
I was wondering if the Nz() function was appropriate. From what I read in Ms Access help, it is used only to return "0" if the related field is empty. Is it true or am I mistaken ?
Mistaken I'm afraid.
If only one parameter passed then it will try to determine the default to use (0 or ""), but you can specify a default (as in the code I provided).
I will need to look at this in more detail. It's not obvious why this is failing atm but I'll give it some further thought when I get some time.
Jan 16 '07 #17
NeoPa
32,556 Recognized Expert Moderator MVP
1. These fields (below), are they TextBoxes on your form too?
[Starting Date]
[Ending Date]
[Time Extension]
[Maintenance Period]
They are all TextBoxes and they all have the same settings.
The code is as follows
Expand|Select|Wrap|Line Numbers
  1. =IIf(Date()<=Nz([Time Extension],[Ending Date]),IIf(Date()<[Start Date],"STARTING","ONGOING"),IIf(Date()<=[Maintenance Period],"MAINTENANCE","COMPLETION"))
In your code you have used [Start Date] but you consistently say that it's [Starting Date].
Can you clarify this please.
If the [Ending Date] control were actually [End Date] then this would explain your problem.
Jan 16 '07 #18
Gari
41 New Member
In your code you have used [Start Date] but you consistently say that it's [Starting Date].
Can you clarify this please.
If the [Ending Date] control were actually [End Date] then this would explain your problem.
Hello NeoPa,

Maybe I was a bit confusing and I apologise for this.

So the fields in my table are as follows:

[Start Date]
[Ending Date]
[Time Extension]
[Maintenance Period]

The code is as follows:

=IIf(Date()<=Nz([Time Extension],[Ending Date]),IIf(Date()<[Start Date],"STARTING","ONGOING"),IIf(Date()<=[Maintenance Period],"MAINTENANCE","COMPLETION"))

Is there any way to attach the database? Maybe this can help...

Best regards,

G.
Jan 16 '07 #19
NeoPa
32,556 Recognized Expert Moderator MVP
That may be a good idea Gari.
I don't say this without first having checked through the code and I can't see why it would have that error.
To find out how to attach a copy, go through this (Check Boxes to Pass into Query) thread paying particular attention to the steps required to make it as small as possible.
Jan 16 '07 #20
Gari
41 New Member
That may be a good idea Gari.
I don't say this without first having checked through the code and I can't see why it would have that error.
To find out how to attach a copy, go through this (Check Boxes to Pass into Query) thread paying particular attention to the steps required to make it as small as possible.
Here is the database.

By the way, when reading the other thread, I've noticed that I did not precise that the form I am using is actually a subform. Those this makes any difference?

Best regards,

G.
Jan 16 '07 #21
NeoPa
32,556 Recognized Expert Moderator MVP
That attach didn't work Gari.
How big is the file in MB?
Yes it did - I hadn't refreshed my browser :(
Jan 16 '07 #22
NeoPa
32,556 Recognized Expert Moderator MVP
Here is the database.

By the way, when reading the other thread, I've noticed that I did not precise that the form I am using is actually a subform. Those this makes any difference?

Best regards,

G.
I expect that makes a big difference actually ;)
Nevermind, I'll have a better understanding when I get this downloaded at home tonight.
Jan 16 '07 #23
Gari
41 New Member
Thank you for support NeoPa !

I have to leave the office now so I will see your messages tomorrow.

See you !

G.
Jan 16 '07 #24
NeoPa
32,556 Recognized Expert Moderator MVP
Here is the database.

By the way, when reading the other thread, I've noticed that I did not precise that the form I am using is actually a subform. Those this makes any difference?

Best regards,

G.
In fact, as all the controls (Status and all dates) are in the same sub form, there shouldn't be a problem here.

Now I have to say the instructions in the other post (which you followed very well - too well in fact) were for a larger database where I didn't need the data so much. Can you make me another copy but with the data in it (If that's very large then lose most of it but make sure you leave enough to exhibit the problem). Don't forget to Compact & Repair before Zipping it up.
Again, I can't see what may be causing this issue - even with a closer look.

When you've posted the new version I'll see if I can delete the old one. I can certainly edit the post to stop linking to it then you may be able to finish off the job in Attachment Management in your Control Panel.
Jan 16 '07 #25
Gari
41 New Member
Hello NeoPa,

Here is the database with a bit of data. I was wondering if you needed some, I should have followed my first thought ^^.

Best regards,

G.
Attached Files
File Type: zip Project Follow up DB_THE SCRIPTS 2.zip (27.9 KB, 109 views)
Jan 17 '07 #26
NeoPa
32,556 Recognized Expert Moderator MVP
Thanks for that Gari - I'll get on to it at home. I don't like to download items at work.
Jan 17 '07 #27
NeoPa
32,556 Recognized Expert Moderator MVP
Gari,
You need to look at your question a little more.
I'm assuming that your requirements are better expressed as (Please notice where I have included & omitted the '='s in my version.) :
I have four Date fields (no time elements) :
  • [Starting Date]
  • [Ending Date]
  • [Time Extension]
  • [Maintenance Period]
All must contain values except [Time Extension] which may be empty. Otherwise the dates are in progressive order.
I have a control which needs to show a string determined by the following logic :
  1. Treat [Time Extension] as [Ending Date] if it is not entered.
  2. If today < [Starting Date], then return "STARTING"
  3. Otherwise if today <= [Time Extension] then return "ONGOING"
  4. Otherwise if today <= [Maintenance Period] then return "MAINTENANCE"
  5. Otherwise (today must be > [Maintenance Period]) return "COMPLETION"
Please can you confirm that this is correct and not a wrong guess.
This is a quote of Post #5 which you confirmed to me was a correct reflection of the situation.
Although there is still confusion in my mind related to the [Time Extension] problem returning #Error, your data certainly doesn't match this specification. The only field in your data which consistently holds data is [Start Date]. All of the other fields are blank (Null) in some instances.
I will look further into this as it wil almost certainly mean some changes in the code but my first task will be to find and fix the issue that should be handled already in the existing code.
Jan 17 '07 #28
NeoPa
32,556 Recognized Expert Moderator MVP
In your 'Relationships' window you have the 'Company' join in twice. You should remove Company_1 version as it seems superfluous.
Jan 18 '07 #29
NeoPa
32,556 Recognized Expert Moderator MVP
I could not find a decent replacement for the formula (I tested that the value returned was Null but it still didn't respond as expected) so I looked at the RecordSource of the subform instead. The changes I made here are threefold :
  1. Tidied up the INNER JOIN as it repeated the fields it connected on ([Account Number] - as per original Relationships).
  2. Changed it from a GROUP BY query to a SELECT but qualifed by the DISTINCT predicate.
  3. Added a Status field with fixed formula (handling all possible Null value dates).
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT 
  2.     Projects.[Project Name],
  3.     Owner.[Owner Name],
  4.     Currency.[Currency Code],
  5.     Projects.[Project Account Number],
  6.     Company.[Account Number],
  7.     Projects.Value,
  8.     Projects.Variations,
  9.     Projects.[Start Date],
  10.     Projects.[Ending Date],
  11.     Projects.[Time Extension],
  12.     Projects.[Maintenance Period],
  13.     IIf(Date()<[Projects].[Start Date],
  14.         'STARTING',
  15.         IIf(Date()<=Nz([Projects].[Time Extension],[Projects].[Ending Date]),
  16.             'ONGOING',
  17.             IIf(Date()<=Nz([Projects].[Maintenance Period],Date()),
  18.                 'MAINTENANCE',
  19.                 'COMPLETION'))) AS Status,
  20.     Projects.ProjectID
  21. FROM Owner RIGHT JOIN 
  22.     ([Currency] RIGHT JOIN 
  23.     (Company INNER JOIN Projects
  24.       ON Company.[Account Number]=Projects.[Account Number])
  25.       ON Currency.CurrencyID=Projects.CurrencyID)
  26.       ON Owner.OwnerID=Projects.OwnerID
The ControlSource for the Status control is now simply Status.
Jan 18 '07 #30
NeoPa
32,556 Recognized Expert Moderator MVP
I can only assume that the TextBox controls convert Null values to empty strings so the Nz() function would never trigger the Replacement or Default value. The solution to put the Result field within the (SQL) query instead works better anyway so there's no need to make up a long & complicated formula for the Result TextBox.
Jan 18 '07 #31
Gari
41 New Member
Dear NeoPa,

Thank you for your answer. I'll have a close look into it and come back to you as soon as possible.

Best regards,

R.
Jan 18 '07 #32
NeoPa
32,556 Recognized Expert Moderator MVP
That's fine Gari.
Don't forget to go through all posts from #28 ;)
Jan 18 '07 #33
Gari
41 New Member
Thanks for reminding me ^^

It is a bit hectic at work those days so do not expect a reply from me before saturday or sunday. I tell you that as a courtesy note ^^.

Best regards,

G.
Jan 18 '07 #34
NeoPa
32,556 Recognized Expert Moderator MVP
I appreciate the courtesy Gari :)
It really does make a difference if members reply - even if - as yours - it's just a coutesy note explaining an expected absence. It reminds one that we're dealing with real people ;)
I won't expect anything more before the weekend but will get a trigger if you (or anyone else) does post in here.

-NeoPa
Jan 18 '07 #35
Gari
41 New Member
Dear NeoPa,

I took the time to finally go through your posts. Here are my replies

The only field in your data which consistently holds data is [Start Date]. All of the other fields are blank (Null) in some instances.
Actually, in an ideal situation, the only field that could be Null is [Time Extension]. But I wanted to test all the possibilities in the code. I guess I was confused between the "ideal" situation that I want to happen, and the day-to-day issue that I might face while running the database. Anyway, sorry for that.

In your 'Relationships' window you have the 'Company' join in twice. You should remove Company_1 version as it seems superfluous.
I've noticed that but surprisingly, I always remove this relationship but still it appears back. There must be some redundancies in the code that I have to go through.

I could not find a decent replacement for the formula (I tested that the value returned was Null but it still didn't respond as expected) so I looked at the RecordSource of the subform instead. The changes I made here are threefold :
Thank you very much for your code, it works really well ! And what I like about it is that it is "clean".

Regarding:

Changed it from a GROUP BY query to a SELECT but qualifed by the DISTINCT predicate.
Can you explain this for me? Being new in access, I don't understand the subtility of it. (I could have not asked you this because your code works perfectly but I like to understand the things I'm doing. It enables me to reproduce them after.)

I can only assume that the TextBox controls convert Null values to empty strings so the Nz() function would never trigger the Replacement or Default value.
Maybe an IIf function stating to replace "" to Null would have worked also? But your code is clearer.


By the way, I want to add a check box that when checked, will allow the form to return "COMPLETED", that is to say that completion has been validated by the user and the project fully achieved.

I have thought of someting like this:

Expand|Select|Wrap|Line Numbers
  1.  IIf(Date()<[Projects].[Start Date],
  2.         'STARTING',
  3.         IIf(Date()<=Nz([Projects].[Time Extension],[Projects].[Ending Date]),
  4.             'ONGOING',
  5.             IIf(Date()<=Nz([Projects].[Maintenance Period],Date()),
  6.                 'MAINTENANCE',IIf([Checkbox]=True,'COMPLETED',
  7.                 'COMPLETION')))) AS Status,
I have not tested it yet (I am working on this database on my freetime only). But what do you think ?

Thank you for all your help.

Best regards,

G.
Jan 21 '07 #36
NeoPa
32,556 Recognized Expert Moderator MVP
Dear NeoPa,

I took the time to finally go through your posts. Here are my replies

The only field in your data which consistently holds data is [Start Date]. All of the other fields are blank (Null) in some instances.
Actually, in an ideal situation, the only field that could be Null is [Time Extension]. But I wanted to test all the possibilities in the code. I guess I was confused between the "ideal" situation that I want to happen, and the day-to-day issue that I might face while running the database. Anyway, sorry for that.
Not a problem.
Over time one gets to realise that precision in database work is more than desirable - it's an absolute necessity.
Many people never get that but if this has helped you to appreciate that then it's worth its weight in gold :)
In your 'Relationships' window you have the 'Company' join in twice. You should remove Company_1 version as it seems superfluous.
I've noticed that but surprisingly, I always remove this relationship but still it appears back. There must be some redundancies in the code that I have to go through.
I'll leave this one with you. With the relationships set up precisely, your other work will be easier and less prone to problems.
I could not find a decent replacement for the formula (I tested that the value returned was Null but it still didn't respond as expected) so I looked at the RecordSource of the subform instead. The changes I made here are threefold :
Thank you very much for your code, it works really well ! And what I like about it is that it is "clean".
For me - that's the highest form of praise. So, thank you for that.

I'll get to the other points when I can as they both take a little more to reply to.
Jan 21 '07 #37
NeoPa
32,556 Recognized Expert Moderator MVP
Regarding:

Changed it from a GROUP BY query to a SELECT but qualifed by the DISTINCT predicate.
Can you explain this for me? Being new in access, I don't understand the subtlety of it. (I could have not asked you this because your code works perfectly but I like to understand the things I'm doing. It enables me to reproduce them after.)
Firstly: I'm very pleased to explain and I like your attitude.
Secondly:
Using GROUP BY is a way to group records together, generally to produce aggregates (Sum; Average; Count; etc), which are not to be found in the original data directly. It can also, of course, be used to lose duplicated data, but it is not a very efficient way to do this. DISTINCT and DISTINCTROW are predicates of the SELECT clause which allow duplicate data to be ignored (dropped from the result set) in a more direct and efficient way.
Jan 21 '07 #38
NeoPa
32,556 Recognized Expert Moderator MVP
I can only assume that the TextBox controls convert Null values to empty strings so the Nz() function would never trigger the Replacement or Default value.
Maybe an IIf function stating to replace "" to Null would have worked also? But your code is clearer.
That would have muddied the waters more than helped the situation I expect.
The reason that the Null can be so much cleaner is because Nz() can be used instead of IIf().
Jan 21 '07 #39
NeoPa
32,556 Recognized Expert Moderator MVP
By the way, I want to add a check box that when checked, will allow the form to return "COMPLETED", that is to say that completion has been validated by the user and the project fully achieved.

I have thought of someting like this:

Expand|Select|Wrap|Line Numbers
  1.  IIf(Date()<[Projects].[Start Date],
  2.         'STARTING',
  3.         IIf(Date()<=Nz([Projects].[Time Extension],[Projects].[Ending Date]),
  4.             'ONGOING',
  5.             IIf(Date()<=Nz([Projects].[Maintenance Period],Date()),
  6.                 'MAINTENANCE',IIf([Checkbox]=True,'COMPLETED',
  7.                 'COMPLETION')))) AS Status,
I have not tested it yet (I am working on this database on my freetime only). But what do you think ?

Thank you for all your help.

Best regards,

G.
Your test will succeed.
However, I've made a slight amendment both to the code and the layout (hopefully to make it easier to read and understand).
Expand|Select|Wrap|Line Numbers
  1.     IIf(Date()<[Projects].[Start Date],
  2.         'STARTING',
  3.         IIf(Date()<=Nz([Projects].[Time Extension],
  4.                        [Projects].[Ending Date]),
  5.             'ONGOING',
  6.             IIf(Date()<=Nz([Projects].[Maintenance Period],Date()),
  7.                 'MAINTENANCE',
  8.                 IIf([Checkbox],'COMPLETED','COMPLETION')))) AS Status,
The beauty of boolean type fields is that it is unnecessary to compare them to anything to get the result.
It is also a better policy as the value (True) is equivalent to -1, but any non-zero value is treated as TRUE.
This means, in some cases that TRUE =/= True. EG. intMyResult = 5: If intMyResult Then {Treated as TRUE} whereas If intMyResult = True {Treated as False as 5 =/= -1}. This will not affect boolean type fields as they can only hold True or False (and sometimes Null in 3-way controls).
Jan 21 '07 #40

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Piotr | last post by:
I have popup window (window.open) where I put any value in input field. After submit I wan to to return to the main window and get value from popup window. How to close popup window and return to...
5
by: jen_designs | last post by:
Is there a way to return the character position on a page? Not the x and y coordinates, but the number of characters on a page. For instance i have a html page with the following text: This is my...
1
by: jen_designs | last post by:
I need to find a way to determine the character position of a users selection in a div. I can do this with the following using an input text box. Any way for a div or any text within the body...
2
by: Neil Schemenauer | last post by:
python-dev@python.org.] The PEP has been rewritten based on a suggestion by Guido to change str() rather than adding a new built-in function. Based on my testing, I believe the idea is...
4
by: WebBuilder451 | last post by:
I have a function that returns a dataset or a boolean depending upon whether a record was found. I can check for the string value of the return type, but i don'r think this is the right way to do...
4
by: AssanKhan Ismail | last post by:
Im using an C#'s user defined private function on which i want to return more than one value (like int and string ) and from that function. please let me know in advance.. assankhan Ismail
3
by: Mike Hoff | last post by:
Hello, I am trying to write a function that will return the value to be stored from any control based on the control's type. So for text boxes and labels it would return the text value, for...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
1
by: David | last post by:
Hi, I have a problem with returning a value from an external function..... My asp page is basically a list taken from a database. A date record is written from the DB, then all the...
8
by: colmkav | last post by:
Can someone tell me how I can access the return value of a function called from Oracle as opposed to a store proc from oracle? my oracle function is get_num_dates_varposfile. I am only used to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.