By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

if else function to fill field on access 2010?

P: 1
Hello guys,

I have this database on access 2010 and I want to fill a field with the use of the "if...else" expression with multiple conditions. From what I found out, the if else expression can only be used on vba. I haven't figured out how to do that yet. My question is, is that something that can be done or am I wasting my time? And if it can be done, could someone help me out?

Thank you so much in advance. I know the very basics of programming, so explain very plainly please...

Thanks again...

VP
May 27 '17 #1

✓ answered by NeoPa

Hi VP.

Phil's absolutely right. If ... Else ... End If is a specifically VBA construct that isn't usable in SQL. Nevertheless SQL does support functions that are publicly available as well as those you may write yourself.

Functions that can be very useful for assigning values depending on other values are many, but include :
IIf(), Switch() & Choose().

You can find more about each of them by typing the name in a VBIDE code pane (The Immediate Pane is always a good one for such things and can be reached by pressigng Ctrl-G.) and pressing F1.

As for helping further at this stage, I'm afraid Phil's right about that too. Without further information from you we'd be at a loss. We all start somewhere though, so I'm sure we can move forward now you understand better. Always assuming you need further help now you already know about some useful functions you can use in SQL.

Share this Question
Share on Google+
2 Replies


PhilOfWalton
Expert 100+
P: 1,430
With so little information to go on, it is unlikely unless one of the contributors is psychic, you will get much help.

Are you talking about queries, or forms?
Where are these multiple conditions coming from?

You are correct that VBA uses the if ... else expression, but look up the Iif function which can be used in a similar fashion in queries, forms & reports. (Iif is not a typo)

Phil
May 27 '17 #2

NeoPa
Expert Mod 15k+
P: 31,419
Hi VP.

Phil's absolutely right. If ... Else ... End If is a specifically VBA construct that isn't usable in SQL. Nevertheless SQL does support functions that are publicly available as well as those you may write yourself.

Functions that can be very useful for assigning values depending on other values are many, but include :
IIf(), Switch() & Choose().

You can find more about each of them by typing the name in a VBIDE code pane (The Immediate Pane is always a good one for such things and can be reached by pressigng Ctrl-G.) and pressing F1.

As for helping further at this stage, I'm afraid Phil's right about that too. Without further information from you we'd be at a loss. We all start somewhere though, so I'm sure we can move forward now you understand better. Always assuming you need further help now you already know about some useful functions you can use in SQL.
May 27 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.