Forums
This topic is locked
Forms & Checkboxes & Databases
Posted 22 Mar 2004 17:57:44
1
has voted
22 Mar 2004 17:57:44 Jack Cider posted:
<font face='Verdana'>OK I have another question that I'm guessing will have a very simple answer. My form submits directly to a database. Some of the fields in the database are just checkboxes (no text field). The form mirrors this (the appropriate questions are answered with checkboxes). What do I need to add to form processing file (which is VBScript) to select the appropriate checkboxes in the database if the corresponding checkboxes on the form are selected? Thanks in advance for all the help.Jack</font id='Verdana'>
Replies
22 Mar 2004 19:16:35 replied:
nothing Usually your check boxes can be either a yes/no true/false or even words. You bind each one to a field in your database. Each field can be set up as a yes/no true/false or whatever you want. Hope that helps
Replied 24 Mar 2004 23:06:01
24 Mar 2004 23:06:01 Jack Cider replied:
<font face='Verdana'>I've tried fooling with this for a couple days now with no success. The problem (in my mind) is that the fields in the database that correspond to the checkbox questions on my form are Yes/No data types. How do I submit from checkboxes in an HTML form to Yes/No data types in a MS Access database? With everything I've tried to set the variables to (1, 0; -1, 0; yes, no; Yes, No), I get the same error:
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement
I only get this error when I include the variables for the checkboxes in my insert statement (even just one of them). Anyone have any ideas? Thanks in advance for the help.
Jack</font id='Verdana'>
Edited by - jackcider on 24 Mar 2004 23:07:35
Edited by - jackcider on 24 Mar 2004 23:54:55
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement
I only get this error when I include the variables for the checkboxes in my insert statement (even just one of them). Anyone have any ideas? Thanks in advance for the help.
Jack</font id='Verdana'>
Edited by - jackcider on 24 Mar 2004 23:07:35
Edited by - jackcider on 24 Mar 2004 23:54:55
25 Mar 2004 18:12:10 replied:
Check to see if the database field Data type is set correctly
Edited by - Lilac Crafts on 25 Mar 2004 18:14:44
Edited by - Lilac Crafts on 25 Mar 2004 18:14:44
Replied 26 Mar 2004 05:58:27
26 Mar 2004 05:58:27 Jack Cider replied:
The data type is set to Yes/No....
Replied 26 Mar 2004 15:31:58
26 Mar 2004 15:31:58 Kristian Waagsboe replied:
You can try setting it to numeric instead and use 0/1 values
.:. DWMX .:. MS IIS 5.1 .:. WinXP .:. MySQL .:. ASP VB
.:. DWMX .:. MS IIS 5.1 .:. WinXP .:. MySQL .:. ASP VB
Replied 29 Mar 2004 21:15:31
29 Mar 2004 21:15:31 Jack Cider replied:
OK, I've gotten past the error message. My form submits to the database, but the information from the checkboxes doesn't. If one is checked, when I look at the datasheet in Access, it still shows up as 0, when it should be -1. I also was able to use Yes/No data types and successfully submit, but again, when I look at the database in the datasheet view in Access, the checkboxes that should be checked remain blank. Any ideas what might cause this? As always help is appreciated. Thanks
Jack
Jack
30 Mar 2004 18:09:35 replied:
Do the check boxes have different names or the same.
Edited by - Lilac Crafts on 30 Mar 2004 18:12:45
Edited by - Lilac Crafts on 30 Mar 2004 18:12:45
Replied 31 Mar 2004 17:37:59
31 Mar 2004 17:37:59 Jack Cider replied:
As far as I know, the variables in the ASP have identical names to the corresponding fields in the database. Each field with a checkbox is named differently though.
Jack
Edited by - jackcider on 31 Mar 2004 17:39:37
Jack
Edited by - jackcider on 31 Mar 2004 17:39:37
31 Mar 2004 18:45:07 replied:
OK If your saying that when you submit a form with a check box and if the value you want is a -1 and its not putting that value in then try this. Go to your datasheet in access and enter in a value of -1 and see what it does. It might change it to a 0. You have to go to design view to change the data type and select what type of format you want. keep playing with this area until the desired data format is what you want. But i would use a word instead of a number in the checked value. Each of your checkboxes unlike radio buttons must have a different field that they submit to.
Replied 31 Mar 2004 19:52:43
31 Mar 2004 19:52:43 Jack Cider replied:
Thanks. I will try that a little later. But just to clarify, when I was working on this the other day, I changed the data type back to Yes/No and tried different formats (True/False, On/Off) and set the checkboxes on the form to submit "True" when checked (also tried "On". When I submitted the info to the database and then went back to the database to look, the checkbox that should have had a check in it was blank. And I encountered the same problem when I switched the data type to Numerical. I set the checkboxes to submit "1" when checked (also tried "-1" later) but when I submitted the form and went back to Access to look at the database, the field that should have been changed to 1 (or -1) still said 0. GRRRRRR! I thought this was gonna be simple... Thanks again for all your help.
Jack
Jack
Replied 31 Mar 2004 23:34:45
31 Mar 2004 23:34:45 Jack Cider replied:
OK I have a small update. I went into the datasheet view in Access like you said. With the fields that were set to Numeric data types, I was able to change them from "0" to "1" and "-1" without a problem. Then, I switched those fields back to Yes/No data types and the fields I manually changed to "1" and "-1" both came up as checked checkboxes. To me this means that what I've been trying should work... Where am I going wrong? <img src=../images/dmxzone/forum/icon_smile_angry.gif border=0 align=middle>
Jack
Jack
01 Apr 2004 00:40:02 replied:
Ok heres what your doing wrong.
A checkbox is designed to put a value you assign when checked to a specific field in your database. There is no unchecked value. IF your going to use a yes/no then I would suggest to use a radio buttons.(those have to have the same field name to work and someone can't select more than one button as with a checkbox in which will cause errors if they are both check and are the same name)
Put two radio buttons and have a text next to each saying yes and one for the other saying no and don't change their label name(they should stay as radiobutton)(if you have other question that your using then the next yes/no set you have to make radiobutton2) just put in yes in the checked value in one and no in the other. Now use the insert server behaviour and have them inserted into the one field where you want the yes/no.
Now in access so that you do not have any trouble in the future,make the field that will be accepting these values just a text field. Don't use numbers unless you require a certain fromat.
And that will work fine.
Dreamweaver cannot detect that check box in access. All dreamweaver is doing is sending a value. I would suggest using text in all your fields in access (unless you need to round up or down or using numbers) I also would recommend to set each field not to require a value in access. That way for some odd reason you have a field and someone leaves blank you son't get an error.
A checkbox is designed to put a value you assign when checked to a specific field in your database. There is no unchecked value. IF your going to use a yes/no then I would suggest to use a radio buttons.(those have to have the same field name to work and someone can't select more than one button as with a checkbox in which will cause errors if they are both check and are the same name)
Put two radio buttons and have a text next to each saying yes and one for the other saying no and don't change their label name(they should stay as radiobutton)(if you have other question that your using then the next yes/no set you have to make radiobutton2) just put in yes in the checked value in one and no in the other. Now use the insert server behaviour and have them inserted into the one field where you want the yes/no.
Now in access so that you do not have any trouble in the future,make the field that will be accepting these values just a text field. Don't use numbers unless you require a certain fromat.
And that will work fine.
Dreamweaver cannot detect that check box in access. All dreamweaver is doing is sending a value. I would suggest using text in all your fields in access (unless you need to round up or down or using numbers) I also would recommend to set each field not to require a value in access. That way for some odd reason you have a field and someone leaves blank you son't get an error.
Replied 01 Apr 2004 12:56:20
01 Apr 2004 12:56:20 Owen Eastwick replied:
You need to send the values 0 and 1 for each checkbox 0 for No/False and 1 for Yes/True, so when you collect the values from the form:
intChecboxValue = Request.Form("chkBoxName"
If intChecboxValue = "" Then intChecboxValue = 0
Then your checkbox:
<input type="checkbox" name="chkBoxName" value="1">
If you want to make it dynamic:
<input type="checkbox" name="chkBoxName" value="1"<% If rsName.Fields.Item("FieldNAme".Vlaue = True Then Response.Write(" checked" %>>
Regards
Owen.
-------------------------------------------------------------------------------------------
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
intChecboxValue = Request.Form("chkBoxName"
If intChecboxValue = "" Then intChecboxValue = 0
Then your checkbox:
<input type="checkbox" name="chkBoxName" value="1">
If you want to make it dynamic:
<input type="checkbox" name="chkBoxName" value="1"<% If rsName.Fields.Item("FieldNAme".Vlaue = True Then Response.Write(" checked" %>>
Regards
Owen.
-------------------------------------------------------------------------------------------
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
Replied 07 Apr 2004 17:54:53
07 Apr 2004 17:54:53 Jack Cider replied:
OK I solved my dilemna. A big part of the problem was that I was using a variable and db field called "User." I was only testing with the User field and variable. I also had three other identical fields that worked the same way as the "User" field and when I tried submitting True and False to the other fields, it worked perfectly. I changed the "User" field and variable to "strUser" and it all works now.
I also had to remove the single quotes from around the variables in my Insert Into statement. But everything works now. Thanks again for all the help.
Jack
I also had to remove the single quotes from around the variables in my Insert Into statement. But everything works now. Thanks again for all the help.
Jack
Replied 26 Apr 2006 01:45:12
26 Apr 2006 01:45:12 Vicki Lozano replied:
Jack,
I am having the same problem with a Yes/No field. Do you mind sharing your code?
Vicki
I am having the same problem with a Yes/No field. Do you mind sharing your code?
Vicki