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

IIF in True/False Checkbox

Status
Not open for further replies.

GWPhoenix

IS-IT--Management
Jun 26, 2001
32
0
0
US


I have a checkbox where if it is checked, the value is "True" going to an Access 97 database.

Problem is, my table is not allowing any but the True value to be entered and will not update the database with a new recordset UNLESS the box is checked (and value would then be TRUE).

Here is my code:

Code:
<TD>Pref EZ/EC?</TD><td><INPUT TYPE='CHECKBOX' NAME='prefezec' VALUE='True'&quot; & IIF(UCase(Value)=&quot;TRUE&quot;, &quot; checked &quot;, &quot;&quot;) & &quot;></TD>

Any way to fix this?
 
Looks to me like you're mixing client and server side code...like you don't understand the difference or somthing. You can't read the client code and use it to make server side decisions before you send the page as it appears you are doing here. But in addition, you didn't really explain what it is you're trying to do...you want it to show up automatically with a check mark? Why are you telling it &quot;value = 'true'&quot; in the tag script?
-Ovatvvon :-Q
 
Sorry if I came off as unclear. I was trying to not enter so much code.

The line of code I entered is part of a &quot;Response.Write&quot; statement. The value is set for true because in an Access Database where the datatype for this question is &quot;Yes/No&quot;, it actually holds a &quot;True/False&quot; value.

I changed an html form to asp in order to include the IIF statement; I get the same results either way: the new recordset does not get added in UNLESS I check the question as &quot;Yes&quot; or &quot;True&quot;.

In HTML:
Code:
<tr><TD>Pref EZ/EC?</TD><td><INPUT TYPE=CHECKBOX NAME=&quot;prefezec&quot;></TD></TR>
Full line in ASP:
Code:
Response.Write &quot;<tr><TD>Pref EZ/EC?</TD><td><INPUT TYPE='CHECKBOX' NAME='prefezec' VALUE='True'&quot; & IIF(UCase(Value)=&quot;TRUE&quot;, &quot; checked &quot;, &quot;&quot;) & &quot;></TD></TR>&quot;




 
The DB field probably requires a Yes/No value, you said Access, right? You can't insert a non Yes/No (True/False) value, it has to have one or the other.
 
I think with Access databases you'll find that whether you use On/Off, True/False or Yes/No data types (why did they even bother?)
it's still stored as 0 for False/Off/No and -1 for True/On/Yes.


codestorm
Fire bad. Tree pretty. - Buffy
Hey, I'm operating on a limited mental budget here.
<insert witticism here>
 
In a &quot;view only&quot; table which displays certain major fields of the recordset, I wanted an &quot;X&quot; where the above value was checked. It only started showing accurately when my &quot;If&quot; statement was &quot;If fieldname = TRUE&quot; after trying &quot;0&quot;, &quot;1&quot;, &quot;on&quot;, etc.

I have found that when I copied the table into SQL, the values became &quot;0&quot; (false) or &quot;1&quot; (true).

But if I want to go with values as &quot;0&quot; or &quot;-1&quot;, is the correct statement:

Code:
Response.Write &quot;<tr><TD>Pref EZ/EC?</TD><td><INPUT TYPE='CHECKBOX' NAME='prefezec' VALUE='-1'&quot; & IIF(UCase(Value)=&quot;-1&quot;, &quot; checked &quot;, &quot;0&quot;) & &quot;></TD></TR>&quot;

?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top