If statement not providing correct result
I have got myself into trouble, but don't understandd what could be the problem.
I have an if statement that does not follow the condition test?
In my recordset I have a field that contains either the word "Withdrawn" or is null.
I assigned this to a string before applying the if statement.
The code is :
If rs.Fields("withdrawnprize").Value <> "" Then
wstatus = rs.Fields("withdrawnprize").Value & " "
MsgBox " rs withdrawnprize is not <> null "
Else
wstatus = ""
End If
If wstatus = "Withdrawn" Then
MsgBox " withdrawnprize record found **** "
chkExpired.Value = 1
Else
chkExpired.Value = 0
MsgBox " what is going on here wstatus " & wstatus
End If
The msgboxs show the recordset column and the string to contain the word Withdrawn , the If statement always branches to the else code?
Can anyone see how I have miss coded this IF logic?
Re: If statement not providing correct result
Quote:
Originally posted by T2T
The msgboxs show the recordset column and the string to contain the word Withdrawn , the If statement always branches to the else code?
Can anyone see how I have miss coded this IF logic?
Back to your original problem, if the message box shows that the field has "withdrawn" in it then it's possible that there is a leading or trailing space on it or that the case doesn't match.
You can test this way
If trim(UCASE(wstatus)) = "WITHDRAWN" then
do what you're going to do
End if