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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use calculated value from form in query?

Status
Not open for further replies.

03SCBeast

Programmer
Jan 26, 2005
36
0
0
US
tbxFirstAidStatus located on frmManagers (underlying tblManagers).

Ideally, I would like to bound the textbox above to a field so I could use it in reports in queries. Is there a way to do this even though the control source is a calculated value. I can do the above with no problem if I do a query based on the underlying table, base a form on the query, and do an expression based with the code below but I'm trying to cut down on any unnecessary queries.

My code for tbxFirstAidStatus: Control Source= IIf(DateDiff("d",Now(),[ASW_FirstAidExp])>30,"Current",IIf(DateDiff("d",Now(),[ASW_FirstAidExp]) Between 0 And 30,"Due",IIf(DateDiff("d",Now(),[ASW_FirstAidExp])<0,"Expired","")))

 
Usually it's a bad idea to store derived/calculated value.
Furthermore tbxFirstAidStatus may change depending current date !
You may simplify your formula:
IIf(DateDiff("d",Now(),[ASW_FirstAidExp])>30,"Current",IIf(DateDiff("d",Now(),[ASW_FirstAidExp]) Between 0 And 30,"Due","Expired"))

You may use it in a query too.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV, I forgot about the principle of not storing a calculated value in a table and I appreciate your simplified formula.
 
Even simpler:
IIf(DateDiff("d",Now(),[ASW_FirstAidExp])>30,"Current",IIf(DateDiff("d",Now(),[ASW_FirstAidExp])<0,"Expired","Due"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top