CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Summarizing a Yes/No Field
One of the possible data types that can be used in Access is a Yes/No data type.  This will allow for input of a simple yes (True) or a no (False).  Summarizing this data type is not done in the same manner as summarizing a numeric value.  The following example will read all the values from an Yes/No field in Access and count the the number of True or False responses and output the totals for each, the total number of observations, as well as the percent of True and False to the total.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<%
'Query the table for all responses
accessdb="yesno" 
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select * from [table]" 
rs.open sql, cn

'move to the first record
rs.movefirst

'starts a loop that will continue until
'there are no more records
do while not rs.eof

'Check the value of the Yes/No field.
'ans_true and ans_false will accumulate
'a numeric summerization of the values contained
'in the table field

if rs("field") = "True" then
ans_true=ans_true+1
end if

if rs("field") = "False" then
ans_false=ans_false+1
end if

rs.movenext
loop

'Output the stats
%>

True: <%= ans_true %> <br>
False: <%= ans_false %> <br>
Total: <%= ans_true + ans_false %> <br>
%True: <%= formatnumber(ans_true/(ans_true + ans_false),2) %> <br>
%False <%= formatnumber(ans_false/(ans_true + ans_false),2) %>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3