Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Playing with Dates 2

Status
Not open for further replies.

uncleG

Technical User
Jun 10, 2004
63
US
On A Form, who's source is a query, the answer does not need to be saved.

I was Trying to make an unbound Text box display one of these 2 Values "On Time" or "Late" based on the value in a third text box.

Text46 =Date() 'Todays Date generated by the system.
rqDelDueOn = 'A Date Entered into the Table by user.
Text44 = 'The place I wanted the value to show. either "On Time" or "Late"

I would prefer to do this in the query and bring it into the form, if possible. Below was my last attempt at the code.

Iff(#[rqDelDueOn]#< or = #[Text46]#,"On Time",Iff(# [rqDelDueOn]# > #[Text46]#,"Late"))

Thanks,Uncle G
 
Hi
Perhaps:
[tt]=IIf([rqDelDueOn]<=Date(),"On Time","Late")[/tt]
Or using the text box:
[tt]=IIf([rqDelDueOn]<=[Text46],"On Time","Late")[/tt]
But perhaps you meant:
[tt]=IIf([rqDelDueOn]>=Date(),"On Time","Late")[/tt]
:)

 
But perhaps you meant:

=IIf([rqDelDueOn]>=Date(),"On Time","Late")"

Thank You Remou

That is exactly what I meant and was looking for, works like a charm.
As you can see I really over did it!

UncleG
 
Some assumption(s) which would need to be considered:

[tab]Can either date (Textbox value) ever NOT represent a date?

Once past this connundrum, the query concept would be -at best= awkward, as it would need to reference at least the one control on the form so you might just as well enter the expression directly in the form (somewhere). We will get back to the where in a bit.

In the simplistic sense, the expression could just be:

IIF(rqDelDueOn <= Text46,"On Time", "Late")

(with the additional 'assumption' that reDelDueOn ~ [reDelDueOn] e.g. the control name is hte same as the bound field.

Back to the location of the (simplified) expression. You need to place hte expression where it will be considered (executed) at the appropiate time. There are a number of different scenarios and situations, such as wheather the form is "contiinous" or single record. If it is a continious form, it needs to be applied to every record whenever the recordsource is altered of if the entered value is changes. Further, in both situatiuons, both values need to be checked to assure that they are 'valid' dates.

Considering that there ends up beiong more checking than doing and that both the checking and doing may need to be done on the basis of miultiple 'events', I would generally advise a small procedure (FUNCTION) either in the form itself or a general module which would be called from the various events which might occur, in particular, I would call the procedure on the after update of the manually entered value and the on current event of the form. Additional events may be necessary, depending on some details of the form use / set up.

Finally, your starting point and my meager revision only allow two states for the result ("Text44"). This is somewhat inadequate, as it ignores the possability that one of more of the operands in the expression is invalidm rendering the expression itself invalid, yet providing only the yes/no response.




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top