Forum Home
Press F1
 
Thread ID: 24159 2002-09-04 20:19:00 Access 2000 macpegbj (1093) Press F1
Post ID Timestamp Content User
76458 2002-09-04 20:19:00 I am developing a database, to replace a Works 4.0 one. In a query I want to use an expression in defining a field such as Newf:IIf(AND([Field a]<>" ",[Field b]=" "),[Field a],IIf([........ I apparently can't use the AND operator as I can in Works or Excel. Is there a way round this or have I got it wrong?

Bruce Mackay
macpegbj (1093)
76459 2002-09-04 21:33:00 Can you post the whole expression you want to use so we can have a look at it? Or a full example at least.

Mike.
Mike (15)
76460 2002-09-06 12:58:00 You have it wrong.

Try =IIf(first condition AND second conditionAND third condition,result if true,],result if false)
Merlin (503)
76461 2002-09-06 13:02:00 Should read

Try =IIf(first condition AND second condition AND third condition,result if true,result if false)

It is also possible to insert OR operators with AND operators.
Merlin (503)
76462 2002-09-07 00:28:00 Hi, until you get more familiar with Access expressions I suggest using the Expression Builder (icon with 3 dots and a wand when in design view). Just select the field function in the bottom pane and use paste to paste that piece into the expression window (top pane). You will see there are operators like AND/Or etc there as well.

cheers
Parry
parry (27)
76463 2002-09-07 05:37:00 Thanks everyone, I have tried the offered suggestion and it works! I think that I had been using the Excel If, then, else structure which requires the AND statement to be enclosed in brackets.

Bruce Mackay
macpegbj (1093)
76464 2002-09-07 06:11:00 Hi macpegbj, Access can be confusing at first. If then else, for next, do loops etc all exist in Access but under code, not expressions. Access uses VBA just like Excel except has some different methods and syntax at times but pretty similar.

Excel has macros and code ... both are the same.
Access has macros, expressions and code - all are different.

Have a look at the help and it will give you an overview.

cheers
Parry
parry (27)
1