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

Conditional Expression in a query

P: 2
I'm so new to this, so you will have to explain every detail to me. Let's say I have field "1" that is populated with either W or B and a second field "2" that is populated with either H or S. If field 1 and 2 = W and H then "Undecided" If field 1 and 2 = B and H then "Non Ex" If field 1 and 2 = B and S then "Ex". Like I said since I'm new I will need you to explain where to place this in the query.

Jan 20 '10 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 1,287
This page has a section on using IIf in a query, and explains it quite fully.
IIf Function[]
Jan 20 '10 #2

P: 2
The link states that is no longer available. I have tried the if statement but it doesn't work. But of course I may not be putting it in the right place. I'm placing it in the criteria of one of the fields.
Jan 20 '10 #3

P: 3
Hello there is a very simple solution. (You solved the problem asking the question, you just need to translate it into VBA code) The following code will mirror your question.

Here's the code...
Place a command button on your form "cmdDecision" and display the results in a textbox or lable. Or in the "AfterUppdate" of field 2.

Private Sub cmdDecision_Cllick()

If Me.Field1 = "W" and Me.Field2 = "H" Then
txtDecision = ""Undecided" or lblDecision = "Undecided"
ElseIf Me.Field1 = "B" and Field2 = "H" then
txtDecision = "NonEx" or lblDecision = "NonEx"
ElseIf Me.Feild1 = "B" and Field2 = "S" then
txtDecision = "Ex" or lblDecision = "Ex"
End Sub

Best Regards,

Lamar Dixon, Jr.
Salient Technologies, LLC
Jan 21 '10 #4

Expert 100+
P: 1,287
Click the words "IIf Function" in my previous post. It seems the forums have included the last ] in the address of the other link, so you could also click that and delete the bracket off the end.
Jan 21 '10 #5

Post your reply

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