PDA

View Full Version : Solved: If and ElseIf Statement



msquared99
08-19-2012, 05:56 PM
Hello, I'm having trouble getting this code to work the way I want it to. Here is the code with comments as to what I am trying to accomplish. I'm sure that I have something out of place. I know I do, I just do not know how to solve it.

Thanks for any help.

'If ComboBox A = Won, If CheckBox A = Checked and If TextBox A < 200 then xMsg = then xMsg = Ver 1 OR
'If TextBox A > 200 then xMsg = Ver 2
If CbxBenexx.Value = "Won" Then
If cb401k.Value = True Then
If tbEECount < 200 Then
xMsg = "Benexx Ver 1"
ElseIf tbEECount > 200 Then
xMsg = "Benexx Ver 2"

'If ComboBox A = None, If CheckBox A = Checked and If TextBox A < 200 then xMsg = then xMsg = Ver 1 OR
'If TextBox A > 200 then xMsg = Ver 2
ElseIf CbxBenexx.Value = "None" Then
If cb401k.Value = True Then
If tbEECount < 200 Then
xMsg = "Benexx Ver 1"
ElseIf tbEECount > 200 Then
xMsg = "Benexx Ver 2"
End If
End If
End If
End If
End If

resString = resString & Delimiter & xMsg

GTO
08-19-2012, 06:30 PM
"Air code" warning, not tested...

If CbxBenexx.Value = "Won" Then
If cb401k.Value = True And tbEECount < 200 Then
xMsg = "Benexx Ver 1"
ElseIf cb401k.Value = True And tbEECount >= 200 Then
xMsg = "Benexx Ver 2"
End If

ElseIf CbxBenexx.Value = "None" Then

If cb401k.Value = True And tbEECount < 200 Then
xMsg = "Benexx Ver 1"
ElseIf cb401k.Value = True And tbEECount >= 200 Then
xMsg = "Benexx Ver 2"
End If
End If

resString = resString & Delimiter & xMsg
Is that closer?

Mark

msquared99
08-19-2012, 07:01 PM
Yes much closer. At least I do not get an error now.

I'll test it much more in-depth on Monday.

It needs a little adjusting. I think I can figure it out. If not I'll post back on here with more details.

Thanks your your time!

Mike

Bob Phillips
08-20-2012, 12:10 AM
Can't you reduce it to

If (CbxBenexx.Value = "Won" Or CbxBenexx.Value = "None") And cb401k.Value Then
If Val(tbEECount.Text) < 200 Then
xMsg = "Benexx Ver 1"
Else
xMsg = "Benexx Ver 2"
End If
End If

resString = resString & Delimiter & xMsg

snb
08-20-2012, 12:17 AM
or to


resString = resString & Delimiter & "Benexx Ver " & iif(Val(tbEECount.Text) < 200,1,2)

msquared99
08-20-2012, 09:24 AM
I could not get either GOT's or xld's code to work like I wanted it. So after reviewing and playing around a bit with the code I realized that I did not care about the value of cb104k. All I really needed was the values of CbxBenexx and tbEECount.

Thanks for everyones input!

After it was all said and done here is code I ended up with:

If CbxBenexx.Value = "None" Then
If Val(tbEECount.Text) < 200 Then
xMsg = "Benexx Ver 1"
Else
xMsg = "Benexx Ver 2"
End If
End If

resString = resString & Delimiter & xMsg