how to insert data into yes/no field

M

middletree

I'm used to SQL Server, but for a project working at home, have to use
Access. On the ASP form, I have some text fields and some checkboxes, and
the text fields work fine. The checkboxes give me errors, though. I'm doing
this from memory, but I beleive the data said I was putting the wrong type
of data into the field.

The HTML for the checkbox is
<input type="checkbox" name="whatever" value="yes">

In Access' design view, the field is clearly a YES/NO field.

When I do a response.write, I get something like
INSERT INTO Tablename (FName,LName,Whatever) VALUES ("Joe","Dirt","yes"),
where the first two fields are text fields and the last one is the field
which is giving me problems.

Do I have to change this to "ON/OFF"? Any other reason I could be having
this trouble?
 
W

William Morris

For Access, send -1 (yes/true/affirmative/whatever) and 0
(no/nada/zippo/false)
 
D

Dan Brussee

I'm used to SQL Server, but for a project working at home, have to use
Access. On the ASP form, I have some text fields and some checkboxes, and
the text fields work fine. The checkboxes give me errors, though. I'm doing
this from memory, but I beleive the data said I was putting the wrong type
of data into the field.

The HTML for the checkbox is
<input type="checkbox" name="whatever" value="yes">

In Access' design view, the field is clearly a YES/NO field.

When I do a response.write, I get something like
INSERT INTO Tablename (FName,LName,Whatever) VALUES ("Joe","Dirt","yes"),
where the first two fields are text fields and the last one is the field
which is giving me problems.

Do I have to change this to "ON/OFF"? Any other reason I could be having
this trouble?

In SQL Server, you use 1 and 0 because the field is a "bit" type. In
Access, it is a boolean (even though they call in Yes/No and show the
words sometimes. Use boolean values...

VALUES ('Joe', 'Dirt', true)
 
M

middletree

Thanks. Kind of makes me wonder why Access gives you the choice of
specifying YES/NO or the other alternatives, though.
 
R

Ray at

Because Access is friendly like that. You can also use TRUE/FALSE. Using
0/1 is the way to go though, as when you upgrade to SQL Server, there will
less code to update if you have SQL queries in your ASP pages.

Ray at work
 
A

Aaron Bertrand - MVP

Partly because Access was designed for people programming in a bubble, with
little hope of ever breaking free. :)

Also, if it were more scalable and behaved more like a real database, sales
for SQL Server would go down considerably.
 
M

middletree

Aaron Bertrand - MVP said:
Partly because Access was designed for people programming in a bubble, with
little hope of ever breaking free. :)


Hey, I resemble that! Seriously, this is the only form on a non-profit
site, and paying $25 per month extra for SQL Server doesn't make sense. In
this case.
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top