473,799 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ 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
39 4317
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,579 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,579 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,579 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,579 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,579 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 "MAINTENANC E"
  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,579 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,579 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

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

Similar topics

1
3441
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 the main after submit?
5
2335
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 string. Then character postion for m would be 9. Any thoughts?
1
19019
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 tags? <html> <body> <form> <div onkeyup="s(this)" onclick="s(this)" id="myDiv">This is some text</div> <input type="text" onkeyup="s(this)" onclick="s(this)" value="This is
2
2635
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 feasible. It would be helpful if people could test the patched Python with their own applications and report any incompatibilities. PEP: 349
4
1660
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 it what is the correct method? any help would be appreciated. (hey, i'm actually learning how to do this "-------"! FUNCTION: ' this function will return the a dataset with the current user if the loogin was successful else if will return a...
4
1950
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
1348
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 list boxes the ListIndex, for combos maybe the Items data etc. with several possible return types (string, int etc). My function (that does not work) is: Public Function SaveValue(ByVal ctrlIn As Control) As VariantType
18
2271
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 then want to use the string on the same page. My script is: function checkRadio(field) { for(var i=0; i < field.length; i++) {
1
1407
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 recordslinked to that date are listed, then the next date, then the next series of records, i.e.
8
11264
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 using this method with store procs that dont return a value back to Access. Hope this makes sense. Set Cmd = New Command With Cmd Set .ActiveConnection = get_XE_Conn 'makes a connection Oracle XE
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10488
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4144
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 we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.