Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Checking check box does not chage query result
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 fiel
d
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>



Report this thread to moderator Post Follow-up to this message
Old Post
Jack
12-16-04 01:55 AM


Re: Checking check box does not chage query result
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" <Jack@discussions.microsoft.com> wrote in message
news:B74F83D6-B19F-43E3-BFA8-367F23D58736@microsoft.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>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Mark Schupp
12-16-04 01:55 AM


Re: Checking check box does not chage query result
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" <Jack@discussions.microsoft.com> wrote in message
> news:B74F83D6-B19F-43E3-BFA8-367F23D58736@microsoft.com... 
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Jack
12-16-04 08:55 PM


Re: Checking check box does not chage query result
Gazing into my crystal ball I observed "Mark Schupp" <notvalid@email.net>
writing in news:eTDafmv4EHA.2568@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

Report this thread to moderator Post Follow-up to this message
Old Post
Adrienne Boswell
12-18-04 05:46 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

ASP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:45 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.