iif

K

kevcar40

i am trying to write a formula that checks for the day of the week
([yellow pages hours 31days].Form!text82="Sat"
i then want to check the score from the night shift
[yellow pages night Scores 31days].Form![5]=0

if the result is Sat and score =0 i want to add days hours(text217] to [text697]

if the result is Sat and score <> 0 i want to add days hours(text217] to [text514]

if the result is <> Sat and score 0 i want to add days hours(text217] to [text514]

formula i trying
IIf([yellow pages hours 31days].Form!text82="Sat" And [yellow pages night Scores 31days].Form![5]=0,([Text217]+[Text697]),([Text514]+[Text217]))
 
A

Access Developer

I suspect you need to provide more detail about where you are executing this
code or using this formula, its context, and what, exactly you are expecting
as a result. I ask because, for example, the first line of code appears to
be addressing a Control named "text82" in the Form object of a Subform
Control named [yellow pages hours 31 days]. If that code is executed from
an event in the parent form that contains the Subform Control, it would be
more usual for it to read:

Me![yellow pages hours 31days].Form!text82

or if executing it in a standard module, a reference to the parent form in
the Forms collection instead of the Me 'shorthand'.

Larry Linson
Microsoft Office Access MVP

P. S. Just a tip: unless your memory is better than most of us have, you
will likely make your work easier if you will rename the Controls from their
default "textXX" names to something more meaningful. Many experienced
Access developers use a naming convention created by Greg Reddick and
documented at his site, http://www.xoc.net/standards/.
 
Joined
Apr 4, 2011
Messages
18
Reaction score
0
Hi

I think Larry Linson probably gets what you are refering to better than me and some more direct referencing like he suggests may be the answer. I also would advise trying to use standard naming conventions - I find it is easier for me to read my own stuff especially after moving on to new databases then coming back to the old ones later. Plus it will be easier to get help on things.

I am responding because although using IIF for your task may or may not be the answer, I thought you may not mind being picked up on an apparent error - just so you know for future.

It appears that you are thinking If Saturday and score =0 then do one thing, else if it is Saturday and score is <>0 then do another. But your attempted expression will ‘do another’ ie add text514 to text217 even if <>Sat because it is attempting to actually say if conditions =Sat and Score =0 are not both true at the same time then for any other combination add text514 to text217

Regards, Mike :)
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top