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

Checkbox function

Status
Not open for further replies.

chinedu

Technical User
Mar 7, 2002
241
US
Hello everyone,

A former partner of mine has just written a code that would list all toys that have not been sold.

The code works fine except that there is a field called sold which determines whether a toy has been sold or not.

When records are displayed, sold will have a value of True displayed on the form.

We would like to change this value from True to a checkbox.

Normally, I would have no problem creating an input box with checkboxes, with an if statement that says if toy is sold, put a checkmark on the chekbox, otherwise leave it blank.

Given the way the code is written, I am stumped with trying to find a solution.

sold is an access database field with yes/no datatype.

Below is the relevant code.

If you would be kind to help with a function that will allow me to change the value of sold from True to a checkbox, this would be greatly appreciated.

Thank you very much in advance.

Code:
function PagingDisplay()

	if strCol = "" then strCol = "toy_Name"
	strSQL = "SELECT id, toy_name,sold " & _
	"FROM toynames where sold = True"
	if strCol <> "" then strSQL = strSQL & "ORDER BY " & strCol & " " & strSrt

	strHeader = "<table border='0' cellspacing='1' cellpadding='2' width='660'> " & _
		"<tr bgcolor=B6C7E5> " & _
		"<td class='header10'><| col_u_1 |><b>First Name</b><| col_d_1 |></td> " & _
		"<td class='header10'><| col_u_2 |><b>Toy Name</b><| col_d_2 |></td> " & _
		"<td class='header10' align='right'><| col_u_3 |><b>sold</b><| col_d_3 |></td> " & _
		"</tr>"

	strTemplate = "<tr class='<| class |>'> " & _
		"<td class='smalltext' valign='top'><a href='<| link |>'><| row1 |></a></td> " & _
		"<td class='smalltext' valign='top'><| row2 |></td> " & _
		"<td class='smalltext' valign='top'><| row3 |></td> " & _
		"</tr>"

	strFooter = "</table>"

	strNavigation = "<table border='0' cellspacing='1' cellpadding='2' width='700'> " & _
		"<tr bgcolor=FFFFFF> " & _
		"<td class='smalltext'><| navigation |></td> " & _
		"</tr></table>"

	iNumberOfFields = 3
	Set objPagination = New cPagination
	objPagination.DetailString = "NorthIndex.asp?report=2&key="
	objPagination.SQLString = strSQL
	objPagination.NumberOfFields = iNumberOfFields
	redim strFormat(iNumberOfFields)
	strFormat(0) = ""
	strFormat(1) = ""
	strFormat(2) = ""
	objPagination.DataFormat = strFormat
	redim strSort(iNumberOfFields)
	strSort(0) = "id"
	strSort(1) = "toy_name"
	strSort(2) = "sold"  <-- the function call will be here.
	objPagination.SortColumns = strSort
	objPagination.SortOrder = strSrt
	objPagination.SortField = strCol
	redim strSum(iNumberOfFields)
	strSum(0) = ""
	strSum(1) = ""
	strSum(2) = ""
	objPagination.SumColumns = strSum
	objPagination.RecordsPerPage = 10
	objPagination.TemplateHeader = strHeader
	objPagination.Template = strTemplate
	objPagination.TemplateFooter = strFooter
	objPagination.TemplateNavigation = strNavigation
	response.write objPagination.ShowRecords(iPageCurrent)
	Set objPagination = nothing

end function


 
you will have to edit the templates and the function (ShowRecords) in the class definition file.

here's the original article the code came from.




Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Oh wow, that is soooo cool.

Thanks Chris.

However, I have come up with a workaround to the problem and have actually come up with something that allows me to use input box.

Here it is:
Code:
					<td>
	            <%
	              IF trim(objRs("Printed")) = "True" then
			         Response.Write("<INPUT CHECKED TYPE=checkbox VALUE=" & objRs("Printed") & ">")
                  ELSE
            		 Response.Write("<INPUT TYPE=checkbox VALUE=" & objRs("Printed") & " >")
	              END IF
	             %>
                   </td>

The only problem with this right now is that everything gets checked even if sold = false.

What am I doing wrong now?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top