Help please with IIF function

  • Thread starter Thread starter Julie Nicole
  • Start date Start date
J

Julie Nicole

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
 
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

If you're entering data in a Table then the answer is - no, there is
no way to do this; Tables have no usable events and cannot do what you
ask.

In a Form, you can put either a Macro or (better) and Event Procedure
in VBA in the BREED control's AfterUpdate event. I'd suggest the
following code: click the ... icon, invoke the Code Builder, and edit
the two lines Access gives you to

Private Sub Breed_AfterUpdate()
Select Case Me.Breed
Case "Siamese"
Me.[Eye Color] = "Blue"
Case "OSH"
Me.[Eye Color] = "Green"
Case "Lynx"
Me.[Eye Color] = "Yellow-orange"
End Select
End Sub

(just throwing in an extra to show how it would be done)
 
Hi John,

Thanks so much for the detailed instructions.
I have entered the below script into the code builder under Breed,
AfterUpdate event etc., just cut and paste over what was there but nothing
shows up in the Eye Colour Box at all.
I did this in the Form not the Table.
Youd think those instructions would have been simple to follow!
What am I not doing correct?

Should there be some sort of settings in the eye colour field in the table
thats not right so the above doesnt work. Im lost.

regards
Julie

John Vinson said:
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

If you're entering data in a Table then the answer is - no, there is
no way to do this; Tables have no usable events and cannot do what you
ask.

In a Form, you can put either a Macro or (better) and Event Procedure
in VBA in the BREED control's AfterUpdate event. I'd suggest the
following code: click the ... icon, invoke the Code Builder, and edit
the two lines Access gives you to

Private Sub Breed_AfterUpdate()
Select Case Me.Breed
Case "Siamese"
Me.[Eye Color] = "Blue"
Case "OSH"
Me.[Eye Color] = "Green"
Case "Lynx"
Me.[Eye Color] = "Yellow-orange"
End Select
End Sub

(just throwing in an extra to show how it would be done)
 
I believe the code may not be changing the eye color
because of the difference in spelling of eye "color".
Update the code to "colour" where it appears as "color" to
match your field name.
-----Original Message-----
Hi John,

Thanks so much for the detailed instructions.
I have entered the below script into the code builder under Breed,
AfterUpdate event etc., just cut and paste over what was there but nothing
shows up in the Eye Colour Box at all.
I did this in the Form not the Table.
Youd think those instructions would have been simple to follow!
What am I not doing correct?

Should there be some sort of settings in the eye colour field in the table
thats not right so the above doesnt work. Im lost.

regards
Julie

types that can go in
this (Eye Colour) I want
to automatically. If it is
Siamese this possible? Is
the heck is the
code!!!!!
thanks
Julie

If you're entering data in a Table then the answer is - no, there is
no way to do this; Tables have no usable events and cannot do what you
ask.

In a Form, you can put either a Macro or (better) and Event Procedure
in VBA in the BREED control's AfterUpdate event. I'd suggest the
following code: click the ... icon, invoke the Code Builder, and edit
the two lines Access gives you to

Private Sub Breed_AfterUpdate()
Select Case Me.Breed
Case "Siamese"
Me.[Eye Color] = "Blue"
Case "OSH"
Me.[Eye Color] = "Green"
Case "Lynx"
Me.[Eye Color] = "Yellow-orange"
End Select
End Sub

(just throwing in an extra to show how it would be done)


.
 
Hi Bob,

That was a good idea, but I changed the spelling and still nothing comes up!

Any other suggestions would be much appreciated.

regards
Julie

Bob said:
I believe the code may not be changing the eye color
because of the difference in spelling of eye "color".
Update the code to "colour" where it appears as "color" to
match your field name.
-----Original Message-----
Hi John,

Thanks so much for the detailed instructions.
I have entered the below script into the code builder under Breed,
AfterUpdate event etc., just cut and paste over what was there but nothing
shows up in the Eye Colour Box at all.
I did this in the Form not the Table.
Youd think those instructions would have been simple to follow!
What am I not doing correct?

Should there be some sort of settings in the eye colour field in the table
thats not right so the above doesnt work. Im lost.

regards
Julie

On Wed, 21 Jul 2004 16:56:14 +1200, "Julie Nicole"

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




If you're entering data in a Table then the answer is - no, there is
no way to do this; Tables have no usable events and cannot do what you
ask.

In a Form, you can put either a Macro or (better) and Event Procedure
in VBA in the BREED control's AfterUpdate event. I'd suggest the
following code: click the ... icon, invoke the Code Builder, and edit
the two lines Access gives you to

Private Sub Breed_AfterUpdate()
Select Case Me.Breed
Case "Siamese"
Me.[Eye Color] = "Blue"
Case "OSH"
Me.[Eye Color] = "Green"
Case "Lynx"
Me.[Eye Color] = "Yellow-orange"
End Select
End Sub

(just throwing in an extra to show how it would be done)


.
 
Hi Bob,

Now I feel stupid.
I have just realised that the code I copied states "AfterUpdate event"
So when I had the form open and jumped from record to record I saw no auto
entry in the eye colour field BUT when I re-enter the Breed the Eye Colour
automatically goes in!!!!!!!

Thanks to you both so much for your help. Its very much appreciated

regards
Julie


Julie Nicole said:
Hi Bob,

That was a good idea, but I changed the spelling and still nothing comes up!

Any other suggestions would be much appreciated.

regards
Julie

Bob said:
I believe the code may not be changing the eye color
because of the difference in spelling of eye "color".
Update the code to "colour" where it appears as "color" to
match your field name.
-----Original Message-----
Hi John,

Thanks so much for the detailed instructions.
I have entered the below script into the code builder under Breed,
AfterUpdate event etc., just cut and paste over what was there but nothing
shows up in the Eye Colour Box at all.
I did this in the Form not the Table.
Youd think those instructions would have been simple to follow!
What am I not doing correct?

Should there be some sort of settings in the eye colour field in the table
thats not right so the above doesnt work. Im lost.

regards
Julie

On Wed, 21 Jul 2004 16:56:14 +1200, "Julie Nicole"

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




If you're entering data in a Table then the answer is - no, there is
no way to do this; Tables have no usable events and cannot do what you
ask.

In a Form, you can put either a Macro or (better) and Event Procedure
in VBA in the BREED control's AfterUpdate event. I'd suggest the
following code: click the ... icon, invoke the Code Builder, and edit
the two lines Access gives you to

Private Sub Breed_AfterUpdate()
Select Case Me.Breed
Case "Siamese"
Me.[Eye Color] = "Blue"
Case "OSH"
Me.[Eye Color] = "Green"
Case "Lynx"
Me.[Eye Color] = "Yellow-orange"
End Select
End Sub

(just throwing in an extra to show how it would be done)





.
 
John,

You mentioned that it is possible to accomplish the same thing with a macro.
How would you do this with a macro?

John Vinson said:
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

If you're entering data in a Table then the answer is - no, there is
no way to do this; Tables have no usable events and cannot do what you
ask.

In a Form, you can put either a Macro or (better) and Event Procedure
in VBA in the BREED control's AfterUpdate event. I'd suggest the
following code: click the ... icon, invoke the Code Builder, and edit
the two lines Access gives you to

Private Sub Breed_AfterUpdate()
Select Case Me.Breed
Case "Siamese"
Me.[Eye Color] = "Blue"
Case "OSH"
Me.[Eye Color] = "Green"
Case "Lynx"
Me.[Eye Color] = "Yellow-orange"
End Select
End Sub

(just throwing in an extra to show how it would be done)
 
Back
Top