Checking check box does not chage query result

J

Jack

Hi,
I have a form when loaded, retrieves record from an access table. Among
other fields there is a check box called FinalUpdate. This is tied to a field
in Access of type Yes/No.
The form retieves the values perfectly. This form is being used to update
the record in the table via a successconfirmation.asp.

Now, when the checkbox is loaded as checked, then unchecking the checkbox
reflects the change in query result in successconfirmation.asp. However, if
the form is loaded as unchecked, and then the checkbox is checked, the final
query does not change the result. The value of FinalUpdate is still False
though it should be True. Any help is appreciated.

MAIN CODE FOR THE successconfirmation.asp
'Store the values to the local variables

l_ss = Request.Form("txtSocialSecurity")
l_firstname = Request.Form("txtFirstName")
l_lastname = Request.Form("txtLastName")
l_password = Request.Form("txtPassword")
l_colorpreference = Request.Form("txtColorPref")
l_foodpreference = Request.Form("txtFoodPref")
l_finalupdate = CBool(Request.Form("chkFinalUpdate"))


Response.Write l_finalupdate


'Create the dynamic sql script for database update corresponding to
'the current record.

strsql = "UPDATE main SET main.FirstName ='" & l_firstname & "', " & _
"main.LastName = '" & l_lastname & "', " & _
"main.ColorPreference = '" & l_colorpreference & "', " & _
"main.FoodPreference = '" & l_foodpreference & "', " & _
"main.FinalUpdate = " & (l_finalupdate) & " where "
& _
"main.SocialSecurityNumber ='" & l_ss & "'"

Response.Write strsql

MAIN CODE FOR THE LOADING OF INITIAL FORM:

Dim l_SocialSecurityNumber
Dim l_Password
Dim l_FirstName
Dim l_LastName
Dim l_ColorPreference
Dim l_FoodPreference
Dim l_FinalUpdate

'Get all the fields from the database in the above variable

l_SocialSecurityNumber = RS.Fields("SocialSecurityNumber")
l_Password = RS.Fields("Password")
l_FirstName = RS.Fields("FirstName")
l_LastName = RS.Fields("LastName")
l_ColorPreference = RS.Fields("ColorPreference")
l_FoodPreference = RS.Fields("FoodPreference")
l_FinalUpdate = CBool(Rs.Fields("FinalUpdate"))

%>

<div ALIGN="CENTER">
<big> <big><font COLOR="navy">Locking Test</big></big>
</div>
<br><br>
<form ACTION="successconfirmation.asp" method="POST" NAME="frmLockTest">
<table>

<tr>
<td HEIGHT="50" COLSPAN="2"><b><font COLOR="green">Edit Screen</font><b></td>
</tr>

<tr>

<td>Social Security Number</td>
<td><input TYPE="text" NAME="txtSocialSecurity" SIZE="15" value =
"<%Response.Write l_SocialSecurityNumber%>"></td>

<td>First Name</td>
<td><input TYPE="text" NAME="txtFirstName" SIZE="15" value =
"<%Response.Write l_FirstName%>"></td>

<td>Last Name</td>
<td><input TYPE="text" NAME="txtLastName" SIZE="15" value =
"<%Response.Write l_LastName%>"></td>
</tr>

<tr>

<td>Password</td>
<td><input type="password" NAME = "txtPassword" size="15" value =
"<%Response.Write l_Password%>"></td>


<td>Color Preference</td>
<td><input TYPE="text" NAME="txtColorPref" SIZE="15" value =
"<%Response.Write l_ColorPreference%>"></td>

<td>Food Preference</td>
<td><input TYPE="text" NAME="txtFoodPref" SIZE="15"value =
"<%Response.Write l_FoodPreference%>"></td>
</tr>


<tr>
<td>FinalUpdate</td>
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE=
"<%=CBool(l_FinalUpdate)%>"<%If CBool(l_FinalUpdate) Then Response.Write "
checked" Else Response.Write " unchecked"%>></td>
</tr>
 
M

Mark Schupp

Your input For the checkbox for is returning "false" when checked because
you are setting its value to the previous value of the data element. Try:

<input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "true"
<%If CBool(l_FinalUpdate) Then Response.Write " checked"
Else Response.Write " unchecked"%>>

If Trim(Request.Form("chkFinalUpdate")) = "true" Then
l_finalupdate = True
Else
l_finalupdate = False
End If
 
A

Adrienne Boswell

<input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "true"
<%If CBool(l_FinalUpdate) Then Response.Write " checked"
Else Response.Write " unchecked"%>>

HTML:
<%If condition = true then%>checked<%end if%>

XHTML
<%If condition = true then%>checked="checked"<% end if%>

There is no such attribute as "unchecked". I realise that's client side,
but it's important to know, especially if you are serving documents as
application/xhtml+xml to compliant browsers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top