Join us on Facebook!

Summarizing a Yes/No Field

by admin 1541 views 0 Comments and 0 Rections

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.

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

'move to the first record

'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
end if

if rs("field") = "False" then
end if


'Output the stats
True: <%= ans_true %>

False: <%= ans_false %>

Total: <%= ans_true + ans_false %>

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

%False <%= formatnumber(ans_false/(ans_true + ans_false),2) %>
More Posts in "Tutorials"


blog comments powered by Disqus

Feed Subscription

Get daily inboxed with latest news, reviews and tutorials. Signup now it's free :)

Planetmaks on Twitter

Follow PlanetMaks on Facebook

Recent Comments

Powered by Disqus


32Bit 64Bit 7 Admin Tool Admin Tools Admin-Tool Admin-Tools AdminTool Adobe Adware All-in-One Anti-Spyware Anti-Virus Apple Backup Tools Browser Browsers Changing Default Directory Codec Data Recovery Download Manager Downloads Drive Utilities Driver Drivers Firefox Flash Freeware Google Graphics Internet Tool Internet-Tool Messaging Microsoft Microsoft Tool Micsellonous Monitoring Multimedia Networking News NVidia Office Tool Office-Tool PC Suite Press Release Registry Samsung Security Shareware Software Softwares Tutorials Vista Windows Windows 7 Windows 8