Convert Excel Formula to access

Caben

New Member
Joined
Oct 27, 2013
Messages
3
Hi All,

I never use access but have to create a field in a table with a formula in it. The formula works fine in excel. Does anybody know how to change it to access?

The Excel formula is:

=IF(A3>=400,"Honour",IF((A3>=300)*AND(A3<400),"Merit",IF((A3>=250)*AND(A3<300),"Pass",IF(A3<250,"Fail"))))

I know it should be something like this:

IIf([Score Total]>=400,"Honour",
iIF(([Score Total]>=300*AND<400,"Merit",
iIF(([Score Total]>=250*AND<300,"Pass",
iIF([Score Total]<250,"Fail"
))))

but it is not excepting it. Can anyone find the errors of my ways?:)

Thanks in advance Caben
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
In Access, you cannot put an expression (formula) in a table. This happens in Queries and Forms. The syntax for IF-THEN statements in Access differs slightly from Excel.

Here is a link to show you the syntax. Look at the last example to see the syntax for AND issues.

MS Access: iif Function
 
Upvote 0
I sorted it. Thanks to anyone who was considering help me with it.

This is the expression should it be useful to anybody else:

IIf([Score Total]>=400,"Honour",IIf(([Score Total]>=300) And ([Score Total]<400),"Merit",IIf(([Score Total]>=250) And ([Score Total]<300),"Pass","Fail")))

Hope this helps somebody.

Caben
 
Upvote 0
Thanks for the info Alan. Not sure when expressions were included in Access, I'm using 2010. They can be added to a table in that version anyway and I got it sorted. Thanks for your reply.
 
Upvote 0
2010 is the first version to support calculated fields in tables. For compatibility it's best to stick with the solution Alan provided, which wroks with all versions of Access.

Denis
 
Upvote 0

Forum statistics

Threads
1,215,221
Messages
6,123,701
Members
449,117
Latest member
Aaagu

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