MS Access Forum / Forms / May 2008
Help with IIf Statement
|
|
Thread rating:  |
ADD NEW DATA IN FORM? - 06 May 2008 20:02 GMT Keep in mind that I have most of the fields. the only thing I don't have which should be include in the statement are the dates. I have the RACC field, serving size, sodium, cholesterol etc... I just don't know how to do this IIf statement
SODIUM: Before January 1, 1998: <=480 mg per RACC and per Serving, EXCEPT if RACC <=30g-- <=480 mg per 50 g of food; after January 1, 1998: this level reduces to <=360 mg
CHOLESTEROL: <=60 mg per RACC, per serving, and if RACC <=30g per 50g of food
BruceM - 06 May 2008 20:44 GMT You would probably nest the IIf statements, but not being a dietician or otherwise conversant with the lingo it is difficult for me to know just what you are trying to do. You have <= 480 mg per RACC, but RACC is apparently expressed in grams, so what does "per RACC" mean? Per gram of RACC? To complicate matters, you are testing per RACC and per serving. Is serving a unit, or is it some number of grams, or what? If the former, where does the 50 grams of food fit into the picture? Maybe somebody will understand what you are trying to do, but you may need to explain this in plain language.
> Keep in mind that I have most of the fields. the only thing I don't have > which should be include in the statement are the dates. I have the RACC [quoted text clipped - 9 lines] > CHOLESTEROL: <=60 mg per RACC, per serving, and if RACC <=30g per 50g of > food ADD NEW DATA IN FORM? - 06 May 2008 20:55 GMT HELLO this is what I came up with but isn't working properly...I need a beginning and ending dates....where does the "EXCEPT AND DATE FIT???
Sodium Healthy Claim1:IIf([Food Type]="Individual Foods",IIf([Sodium (mg)]<=(480/([RACC]*1000))," Low Sodium",""),IIf(([Sodium (mg)]<=(480/([Serving Size]*1000))) And ([Sodium (mg)]<=(480/(50*1000))),"Low Sodium","")),"")
Sodium Healthy Claim2:IIf([Food Type]="Meals/Main Dishes",IIf([Sodium (mg)]<=(600/([RACC]*1000))," Low Sodium",""),IIf(([Sodium (mg)]<=(600/([Serving Size]*1000))) And ([Sodium (mg)]<=(600/(50*1000))),"Low Sodium","")),"")
> You would probably nest the IIf statements, but not being a dietician or > otherwise conversant with the lingo it is difficult for me to know just what [quoted text clipped - 19 lines] > > CHOLESTEROL: <=60 mg per RACC, per serving, and if RACC <=30g per 50g of > > food KARL DEWEY - 06 May 2008 23:16 GMT Post your table structure - fields names and datatype. [Food Type] [RACC] [Sodium (mg)] [Serving Size] cholesterol ?? Some date ??
 Signature KARL DEWEY Build a little - Test a little
> HELLO > this is what I came up with but isn't working properly...I need a beginning [quoted text clipped - 33 lines] > > > CHOLESTEROL: <=60 mg per RACC, per serving, and if RACC <=30g per 50g of > > > food ADD NEW DATA IN FORM? - 07 May 2008 13:25 GMT I have [Food Type], [RACC], [Sodium (mg)], [Serving Size] [cholesterol] I don't have any fields for the dates and I don't understand if those dates should be fields? I also don't understand what "EXCEPT" is suppose to give or do in the IIF statement. Anyway here what I have and it didn't work?
Sodium Healthy Claim1:IIf([Food Type]="Individual Foods",IIf([Sodium (mg)]<=(480/([RACC]*1000))," Low Sodium",""),IIf(([Sodium (mg)]<=(480/([Serving Size]*1000))) And ([Sodium (mg)]<=(480/(50*1000))),"Low Sodium","")),"")
> Post your table structure - fields names and datatype. > [Food Type] [quoted text clipped - 41 lines] > > > > CHOLESTEROL: <=60 mg per RACC, per serving, and if RACC <=30g per 50g of > > > > food BruceM - 07 May 2008 15:03 GMT In your original post you stated the conditions "Before Jan. 1, 1998" and "On or after Jan.1, 1998". If those dates aren't fields, where do they come from? Do you have just one table? Please post some sample data (a simplified version would be fine). Don't assume any of us know what RACC is. You are performing math on it, so presumably it is a number. Is that correct? In my first response I asked that you describe in plain language what you need to do. That would still be helpful. Another thing that would help is knowing what you expect from the IIf statements, and in what way they do not work. What happens if FoodType is not "Individual Foods", or if sodium is above the level determined by the calculation? Is anything other than "Low Sodium" an empty string? Is there no "High Sodium"? An IIf statement may not be the best approach, but again there is no way to know without understanding something of what you are trying to do.
>I have [Food Type], [RACC], [Sodium (mg)], [Serving Size] [cholesterol] > I don't have any fields for the dates and I don't understand if those [quoted text clipped - 70 lines] >> > > > 50g of >> > > > food
|
|
|