Solved

Radio Buttons records wrong input in Access Database

Posted on 2004-08-25
5
133 Views
Last Modified: 2010-04-25

Hello,

I have an ongoing problem with a form made in DW which inserts the wrong input into Access database.

I have an open question here:
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21106199.html

And getting really desprate. I thought maybe in the DW section i have better luck.

0
Comment
Question by:polaatx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
alexhogan earned 500 total points
ID: 11899163
Try this;

<input name="publicTransportation" type="radio" value="-1">
Yes
<input name="publicTransportation" type="radio" value="0">
No</p>

Access is a little weird in that on a Yes/No field -1 equates to a True or Yes state while 0 equates to a False or No state.

This isn't really that uncommon in structured languages where 0 is False and anything not 0 is True even a -1.  This should not however be related to a NULL value.  A 0 is not a NULL value but a 0 value.  So any check for IsNull on a field with a 0 value will render False.
0
 

Author Comment

by:polaatx
ID: 11899263
Hi alexhogan,

I've tried the -1 ,0 combination.

I built this form: http://www.aurafellows.net/aura/testForm_insert.asp 
which insert into a yes/no Access field.

No matter what combination I use (yes/no, -1/0, 1/0, true/false) the input into database is ALWAYS either true or false.

I have search Dreamweaver's forum and support site to no avail.

Here's my html:

<form name="form1" action="<%=MM_editAction%>" method="POST">
<p>Do you have transportation to another institution?
&nbsp;&nbsp;
<input name="publicTransportation" type="radio" value="-1">
Yes  
<input name="publicTransportation" type="radio" value="0">
No
</p>
<p><input name="submit" type="submit">
<input type="hidden" name="MM_insert" value="form1">
</form>

And here's the insert statement:



If (CStr(Request("MM_insert")) = "form1") Then

  MM_editConnection = MM_connTest_STRING
  MM_editTable = "CheckboxTest"
  MM_editRedirectUrl = "testForm_insert.asp"
  MM_fieldsStr  = "publicTransportation|value"
  MM_columnsStr = "publicTransport|none,-1,0"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
0
 

Author Comment

by:polaatx
ID: 11908151
Anyone with ideas on how to troubleshoot this?

I left messages on DW forum and elsewhere and nothing! Not even similar problem on Google Groups.
0
 

Author Comment

by:polaatx
ID: 11924421
I found the answer to this problem on the DW forum on Macromedia site.

Turns out for radio buttons, in DW one has to have the insert dialog submit the data as TEXT.

What is the procedure for closing a question if I found my answer elsewhere?
0
 
LVL 8

Expert Comment

by:alexhogan
ID: 11924551
Go to the support area and request that the question be closed and points refunded.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question