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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yes/No Form Woes

Status
Not open for further replies.

esearing

IS-IT--Management
Aug 22, 2000
132
US
MSAccess 97 database contains a Yes/No fieldType (Boolean)

Collecting data on HTML Form CheckBox, processed using ASP (hidden page2). Having trouble identifying enumtype in CreateParameters statement

HTML INPUTFORM1
<INPUT TYPE=&quot;checkbox&quot; name=&quot;AdLaw&quot; value=&quot;Yes&quot;>
<!-- if checked returns value yes-->

ASP PAGE2
CommandObject.Parameters.Append _
CommandObject.CreateParameter(&quot;AdLaw&quot;,11, ,1 )
' 11=bool 1=maxlength(also tried 2-5)

Returns error message indicating wrong 'type'

If I use a string/text type (like 200,adVarChar) I get a message indicating invalid string length if not checked.

Work around has been to create dropdown yes/no and change database field type to text. But it is not what the users want. There are several of these checkboxes to be checked, each has own name.
Eric

If you create something idiot proof,
Nature will create a better idiot.
 
I'm fuzzy as to what you are doing but if you need to pass a boolean, pass True, False or a boolean expression e.g.
(Lcase(Request.Form(&quot;adLaw&quot;)) = &quot;yes&quot;)
 
Or even a 0 or 1 --

This way, then you can evaluate the value like so:

if (cint(request.form(&quot;value&quot;)))

anything 0 will evaluate as false, and then you can take action (plug in a 1 or 0 in a yes/no field -- that will work), and anything non-zero will evaluate as true, then take action --

:)
Paul Prewett
 
The problem is not passing the Yes/No. I can write to the screen just fine. For some reason the error only occurs with MSAccess. Code above works with SQL Server boolean field.

Even rewrote the code using recordSet objects and still can not get Access to accept novalue if the checkbox is not checked. The default for the field is No/Off/0.

If anyone can point me to an example with checkboxes, would much appreciate it.
Eric

If you create something idiot proof,
Nature will create a better idiot.
 
Ok -- you are going to have to create a separate variable to hold the INSERT value -- and evaluate that value of the checkbox upon loading of the page, and then use that value (that you have explicitly set one way or the other) for the INSERT (or .createParameter or whatever) --

dim adLaw
if request.form(&quot;adLaw&quot;) = &quot;yes&quot; then
adLaw = &quot;yes&quot;
else
adLaw = &quot;no&quot;
end if

Now, you can use adLaw (the vbScript variable) to do your thing.

:)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top