Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf function to set a constant value if combo box is Yes/No

Status
Not open for further replies.

murphy123

Technical User
Feb 18, 2006
41
US
Hi,

I have two fields on my form where I am trying to set values depending if field [Answer] is "Yes" or "No".

Field one [Answer] contaings a drop down box "Yes" and "No". Set up on my table as text and a combo box w/Yes and No.

Field two [Points] should contain the set value. Set up on my table as number.

If [Answer] = "Yes" [Points] = 5
If [Answer] = "No" [Points] = 0

I tried a couple of things on the control source of the textbox but it didn't work...

IIf([Answer] = "Yes", [Points], 5,0) It didn't work


I also tried...

Private Sub Points_AfterUpdate()
If Me.Answer = Yes Then
Me.Points = 5
Else
' do nothing
End If

End Sub


It didn't work either, is there anything else that I can do?
 
Perhaps this ?
Me!Points = IIf(Me!Answer = "Yes", 5, 0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

I tried to use it under the AfterUpdate coding event procedure and it didn't work. Should I tried the same coding somewhere else?

Thanks.
 
PHV,

Never mind, I was adding the coding to the incorrect field. It's all good now. Thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top