How to write back to Access-2000 Yes/No fields

L

Les Juby

Getting really stumped here.....

Using Classic.ASP and after an editing page has been completed I need
to write the values back to an Access 2000 database. But I'm battling
with a checkbox resultwhich has to be stored in aYes/No field.

I'm testing the variable no_mail to see if it returns "on" in ASP
which means the checkbox is ticked. I then load a variable called
sql_val_no_mail with the text that the SCP statement will use to
update into Access.

ie.
If no_mail = "on" Then
sql_val_no_mail = "Yes"

and then.....
" no_e-mail='" & sql_val_no_mail & "',"
goes into the SQL string

But what do you feed into Access for the Yes/No field to record a
positive

Tried: Yes "Yes" True "True" 1 "1" 0 "0" on

Any suggestions, please.....

thanks

.les.
 
B

Bob Barrows [MVP]

Les said:
Getting really stumped here.....

Using Classic.ASP and after an editing page has been completed I need
to write the values back to an Access 2000 database. But I'm battling
with a checkbox resultwhich has to be stored in aYes/No field.

I'm testing the variable no_mail to see if it returns "on" in ASP
which means the checkbox is ticked. I then load a variable called
sql_val_no_mail with the text that the SCP statement will use to
update into Access.

ie.
If no_mail = "on" Then
sql_val_no_mail = "Yes"

and then.....
" no_e-mail='" & sql_val_no_mail & "',"
goes into the SQL string

But what do you feed into Access for the Yes/No field to record a
positive

Tried: Yes "Yes" True "True" 1 "1" 0 "0" on

-1 = true/yes/on
0 = false/no/off

Write the numeric value to the database field
 
B

Bob Barrows [MVP]

Les said:
Getting really stumped here.....

Using Classic.ASP and after an editing page has been completed I need
to write the values back to an Access 2000 database. But I'm battling
with a checkbox resultwhich has to be stored in aYes/No field.

I'm testing the variable no_mail to see if it returns "on" in ASP
which means the checkbox is ticked. I then load a variable called
sql_val_no_mail with the text that the SCP statement will use to
update into Access.

ie.
If no_mail = "on" Then
sql_val_no_mail = "Yes"

and then.....
" no_e-mail='" & sql_val_no_mail & "',"
goes into the SQL string

But what do you feed into Access for the Yes/No field to record a
positive

Tried: Yes "Yes" True "True" 1 "1" 0 "0" on

Any suggestions, please.....

thanks

.les.

And stop using dynamic sql. use saved parameter queries (my preference):
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&[email protected]

or

ODBC placeholders (?) with an explicit Command object to pass the values to
the placeholders:
http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e

Bob Barrows
 
L

Les Juby

Oi, thanks for that help.!

I really do take your point about the horrors of dynamic SQL but this
site in particular is full of legacy code so we will have to keep it
in place. But I'm looking hard at switching to the parameter queries.

Main reason for my reply, especially if it can help someone else, is
that the real problem here was that I was using an illegal construct
in the field name. ie.
Once I changed the fieldname from no_e-mail to no_email then the 0 and
-1 was accepted fine.! This particular code is a construction of
backend code to replace manual maintenance of Access databases so the
problem never occurred when an Access Form was being used to update
details. We live and we learn......

Can't even begin to recount how many times I have hit major problems
because of reserved names for fields. Now I need to remember that a
hyphen should probably be always avoided in Access 2000 field names,
especially numeric field names.!

thanks again

.les.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top