Setting checkbox values from an Access database
 
Often you'll want to display a checkbox value stored in an Access database 
in an ASP page. Depending on the setting in your Access table, 
Access may display Yes/No, On/Off, or True/False in the field when 
you view the table in the database. As a result, you may think to use ASP 
similar to:
 
<input type="checkbox" name="chk1" value="Yes" <% if rs("checkfield")="yes"
then %>
checked="checked" <% end if %> />
 
However, this doesn't actually work.  That's because even though 
Access displays the field contents as a Yes or No, it stores the contents as True or False, 
(-1 and 0 respectively). To get an accurate checkbox setting in ASP, use:
 
<input type="checkbox" name="chk1" value="Yes" <% if rs("checkfield")=True
then %>
checked="checked" <% end if %> />
 


Active Server Index

Main Index

Search RD Techbase