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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP error displaying "True/False" db field as yes/no

Status
Not open for further replies.

credo

Programmer
Jul 26, 2001
50
0
0
GB
Hello,

I'm trying to simply display Yes/No instead of True/Fasle from an Access db yes/no field in a table cell - having trouble with the ASP formatting with the following statement :

<td width=&quot;122&quot; valign=&quot;top&quot; class=&quot;gen2&quot;>
<%= If (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = True)

' set the yes/no true/false access field to more friendly yes/no

Response.Write &quot;Yes&quot;
Elseif (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = False) Then
Response.Write &quot;No&quot;
End If
%></td>

this is throwing up the error :
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/bigbluetravel/vd.asp, line 299
= If (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = True)

I've tried various changes ,but am getting same error..

Thanks in advance for any tips...


 
It should read:

<%= If (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = True) Then

Only because I've done it before myself... :)


-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Hi,
Thanks for your quick response Chopstick - but I had'nt left out the first &quot;Then&quot;, it was a code pasting error ... so my code is :

<td width=&quot;122&quot; valign=&quot;top&quot; class=&quot;gen2&quot;>
<%= If (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = True) Then
' set the yes/no true/false access field to more friendly yes/no
Response.Write &quot;Yes&quot;
Elseif (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = False) Then
Response.Write &quot;No&quot;
End If
%></td>

so still getting the same error ...

Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/bigbluetravel/vd.asp, line 303
= If (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = True) Then

 
I typically don't use the ElseIf statement, but if I remember correctly, it reads essentially as a second If statement, so it must therefore have a corresponding End If. In this case, try adding another End If to the bottom of your original If statement:

<td width=&quot;122&quot; valign=&quot;top&quot; class=&quot;gen2&quot;>
<%= If (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = True) Then
' set the yes/no true/false access field to more friendly yes/no
Response.Write &quot;Yes&quot;
Elseif (rs_av.Fields.Item(&quot;w1_Avail&quot;).Value = False) Then
Response.Write &quot;No&quot;
End If
End If
%></td>

-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top