By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,377 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Checking check box does not chage query result

P: n/a
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>
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jack" <Ja**@discussions.microsoft.com> wrote in message
news:B7**********************************@microsof t.com...
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>

Jul 22 '05 #2

P: n/a
Thanks for your generous help. I will test your advise on my application.
Regards.

"Mark Schupp" wrote:
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

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jack" <Ja**@discussions.microsoft.com> wrote in message
news:B7**********************************@microsof t.com...
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>


Jul 22 '05 #3

P: n/a
Gazing into my crystal ball I observed "Mark Schupp" <no******@email.net>
writing in news:eT**************@TK2MSFTNGP10.phx.gbl:
<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.

--
Adrienne Boswell
Please respond to the Group so others can share
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.