Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

True/False IsNull

Status
Not open for further replies.

BarryMVS

IS-IT--Management
Apr 17, 2003
172
GB
Hi all,

I have a form with several checkboxes on it.
The value of these boxes is set to True.
When the box is ticked, the value true is returned in the post data, but if a box isn't ticked, then no value is returned.

I want to have either true or false entered into my MS Access database via an SQL Insert Into statement.

For this reason, I'm trying to come up with a way of checking the value of the field(s) in question and then, if the value is null, changing it to False.

I have triled both of the following, but both return the error of type mismatch.

Code:
fieldname = Nz(fieldname, "False")
fieldname = IIF(IsNull(filedname), "False", fieldname)

Any ideas would be most welcomed.

Thanks,

Barry

ICT Network Administrator
IT Services Manager
 
the field will always get passed in the collection so checking for null is not going to work

you stated >> The value of these boxes is set to True.

don't if this is what you mean
value="true"

it will either be on or not. validate for that and not true/false when it comes over.

also, IIF -- unless that is part of your actual JetSQL statement it is not valid in ASP. unless I'm mistaken

Code:
If Request.Form("checkbox") = "on" Then
    build the update
End If

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
onpnt,

The checkbox fields in the form are set so value="True".

This means that the POST data comes back as 'fieldname=&fieldname=True&fieldname=&'
From the above example, only the middle fieldname has been ticked, thus getting a value returned.

Thanks for your suggestion.

I have got the result I wanted by doing this:
Code:
If fieldname = "" then
fieldname = "False"
end if

That got the correct data results in the database.

Thanks again.

Barry

ICT Network Administrator
IT Services Manager
 
BarryMVS said:
This means that the POST data comes back as 'fieldname=&fieldname=True&fieldname=&'

first, glad you got it going.

I knew what you were saying though in the initial post and how the data comes accross (don it a few times myself ;))

It's sloppy though when boolean is all that needs to be decided. basically a waist of space type situation. just keep that in mind for future development. things get corporation sized, this is frawned upon in many cases.

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
onpnt,

Cheers, I'll bare that in mind for future projects.

THanks,

Barry

ICT Network Administrator
IT Services Manager
 
i also recently finished up a faq on checkbox handling that may be of assistance : faq333-5241

hopefully it may be of assistance

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top