dbTalk Databases Forums  

IIF Function help please

comp.database.ms-access comp.database.ms-access


Discuss IIF Function help please in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Julie Nicole
 
Posts: n/a

Default IIF Function help please - 07-20-2004 , 11:54 PM






I need to create an IIf function.

I have a field called "BREED". There are only two types that can go in this
field, either "Siamese" or "OSH". In the next field (Eye Colour) I want to
enter the eye colour depending on the Breed automatically. If it is Siamese
then the result I want under eye colour is "Blue" and if it is OSH then I
want the eye colour to enter Green automatically. Is this possible? Is the
IIF function the correct one to use, if so, what the heck is the code!!!!!

thanks
Julie



Reply With Quote
  #2  
Old   
Mike Easter
 
Posts: n/a

Default Re: IIF Function help please - 07-21-2004 , 05:20 PM






[posted and mailed]

"Julie Nicole" <julie.holmes (AT) quicksilver (DOT) net.nz> wrote in
news:1090385638.657023 (AT) drone1-svc-skyt (DOT) qsi.net.nz:

Quote:
I need to create an IIf function.

I have a field called "BREED". There are only two types that can go
in this field, either "Siamese" or "OSH". In the next field (Eye
Colour) I want to enter the eye colour depending on the Breed
automatically. If it is Siamese then the result I want under eye
colour is "Blue" and if it is OSH then I want the eye colour to enter
Green automatically. Is this possible? Is the IIF function the
correct one to use, if so, what the heck is the code!!!!!

thanks
Julie
In the field "OSH", you could use IIf in a query like this:

Eye Color: IIf([BREED]="OSH","Green","Blue")

The SQL for that would look like this:

SELECT Table.BREED, IIf([BREED]="OSH","Green","Blue") AS [Eye Color]
FROM Table;

It's important to note that this assumes you will never, ever have
another breed other than Siamese or OSH, though, because you won't be
able to enter an eye color for them through this query.

HTH,

Mike


Reply With Quote
  #3  
Old   
Ray
 
Posts: n/a

Default Re: IIF Function help please - 07-21-2004 , 06:58 PM



"Julie Nicole" <julie.holmes (AT) quicksilver (DOT) net.nz> wrote

Quote:
I need to create an IIf function.

I have a field called "BREED". There are only two types that can go in this
field, either "Siamese" or "OSH". In the next field (Eye Colour) I want to
enter the eye colour depending on the Breed automatically. If it is Siamese
then the result I want under eye colour is "Blue" and if it is OSH then I
want the eye colour to enter Green automatically. Is this possible? Is the
IIF function the correct one to use, if so, what the heck is the code!!!!!

thanks
Julie
Hello Julie,

What you could do is enter the following code into the
"After Update" property of your field:

If Breed.value = "Siamese" Then
EyeColour.value = "Blue"
DoCmd.GoToControl "EyeColour"
ElseIf Breed.value = "OSH" Then
EyeColour.value = "Green"
DoCmd.GoToControl "EyeColour"
Else
MsgBox "Please enter the correct Breed type!", vbCritical, "Enter Correct Breed"
End If

You wouldn't need to use an IIF funtion anywhere. Just
remember to put the above code into the correct
location.

Regards,

Ray


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.