Print Page | Close Window

checkboxes with Access

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1506
Printed Date: 29 March 2026 at 5:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: checkboxes with Access
Posted By: vicky_c
Subject: checkboxes with Access
Date Posted: 31 March 2003 at 6:33am

Hi!  Sorry to bother you guys again but my project is almost done and I have come across a small problem...

Users fill out a form, the contents of which are verified and then written to an Access Database.  One of the objects is a checkbox.  It is asking the user wether or not they wish to receive a newsletter.  In the database, the column for 'newsletter' is in the data type 'yes/no' but I don't know how to write wether it was checked or not into the database.  Can Anyone help?

This is what i have so far for the text fields....

rs("username")=username
rs("password1")=password1
rs("fullname")=fullname
rs("email")=email
rs("location")=location
rs("birthday")=birthday
rs("birthmonth")=birthmonth

I tried rs("newsletter")=newsletter for the checkbox but I got a data mismatch error. 

I'd be really grateful for any help you could give me!  I appreciate what you guys do for us amateurs!

Loadsa love,
Vicky  xxx

 




Replies:
Posted By: ultramods
Date Posted: 31 March 2003 at 8:03am

try IF newsletter = "yes" THEN

newsletter = True

Else

newsletter= False

END IF

rs("newsletter")=newsletter

 



Posted By: vicky_c
Date Posted: 31 March 2003 at 1:30pm

Thanks!!  It's almost working now!  I don't get any errors anymore but when i open the database, boxes that should be checked aren't.

Any idea wots going wrong?

Thanks again!!

Loadsa love,
Vicky  xxx



Posted By: vdub
Date Posted: 31 March 2003 at 1:46pm

I recoment not using the checkboxes in the database.

for a check box I just do this

<%
IF checkbox = "true" Then
SQL = "UPDATE config SET newsleter = 't' WHERE DBID ="& User
    Set RS = DBConnection.Execute(SQL)

ElseIF checkbox = "false" Then
SQL = "UPDATE config SET newsleter = 'f' WHERE DBID ="& User
    Set RS = DBConnection.Execute(SQL)

Else

End IF
%>

Then to to pull the data back out of the database just do this.

<%
SQL = "Select * From newsleter Where DBID ="& user 
      Set RS = DBConnection.Execute(SQL)

      newsleter=RS("newsleter")
%>

Yes<INPUT TYPE="radio"  NAME="news" VALUE="true" <%IF newsleter= "t" Then%>CHECKED<%Else%><%End IF%>>
No<INPUT TYPE="radio" NAME="news" VALUE="false" <%IF newsleter= "f" Then%>CHECKED<%Else%><%End IF%>>


Hope that helps



-------------
http://www.CyberCPU.net - Hardware reviews, Forum, Free advertising!!!!


Posted By: ultramods
Date Posted: 31 March 2003 at 2:32pm
To fix the problem with the database you can change yes/no format from yes/no to true/false. (under the general tab whilst in design view)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net