Solved

Radio Buttons records wrong input in Access Database

Posted on 2004-08-25
5
128 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
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
alexhogan earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Go to the support area and request that the question be closed and points refunded.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now