equivalent of IF in Access? Hopefully something v. simple

vanilladan

Board Regular
Joined
Sep 24, 2002
Messages
145
Howdy folks,
Been a while since I used Access and I'm hoping to get to a proficient level. Anyway, humble beginnings...

I have a Table, Orders.
I have another Table, Item Prices.

I have a query which joins the two tables by 'Item No' (a common field) and then shows the 'Item No' & 'Item Details' from the Order Table with the 'Price' from the Item Prices table.
Problem is this:

There are now TWO different 'Price' fields in Item Price table: '2002 Price' and '2003 Price'.

Solution I want!:

I want Access to decide which field to select from based upon the ORDER DATE field in the Orders table.

Any ideas?
A simple Excel equivalent would be:

VLOOKUP(A1,ItemPrices,IF(B1=2002,2,3),FALSE)

presuming column B housed the 'Order Date' entries.

Cheers guys,

Vanilladan
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi,

You can use the IIf function which has the following syntax:-

IIF(Expression, Value if True, Value if False)

In your case you could use something like this:-

ItemPrice: IIf(Year([Orders]![Order Date])=2002,[Item Prices]![2002 Price],[Item Prices]![2003 Price])

Hope that helps. Post back if not :)
 
Upvote 0

Forum statistics

Threads
1,221,497
Messages
6,160,150
Members
451,626
Latest member
sukhman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top