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

passing variables from one form to another - stumped!

Status
Not open for further replies.

siena

Technical User
Jan 30, 2003
262
US
On the first page, I have this:
<TR>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Department</B>
</TD>
<td><select name=&quot;Driverdept&quot;>
<%
sql = &quot;SELECT tblDept.DeptID, tblDept.DeptName FROM tblDept &quot;
set deptset = safetyDB.Execute(sql)
While not DeptSet.EOF
%>
<option value=&quot;<%=DeptSet(0)%>&quot;><%=DeptSet(1)%></option>
<%
DeptSet.MoveNext
wend
%>
</select>
</td>
</TR>

(of course, there are more form objects on this page)

on another page, I have this:

DriverDept = request.form(&quot;DriverDept&quot;)
LocationDesc = request.form(&quot;LocationDesc&quot;)
AccidentWeather = request.form(&quot;AccidentWeather&quot;)
AccidentFactor = request.form(&quot;AccidentFactor&quot;)
AccidentCollision = request.form(&quot;AccidentCollision&quot;)
AccidentDesc = request.form(&quot;AccidentDesc&quot;)
AccidentDate = request.form(&quot;AccidentDate&quot;)
TimeOfAccident = request.form(&quot;TimeOfAccident&quot;)
TimeOfAccidentAMPM = request.form(&quot;TimeOfAccidentAMPM&quot;)
Age = request.Form(&quot;Age&quot;)
Drug = request.Form(&quot;Drug&quot;)
TestType = request.Form(&quot;TestType&quot;)
Result = request.Form(&quot;Result&quot;)
AtFault = request.Form(&quot;AtFault&quot;)
Condition = request.Form(&quot;Condition&quot;)
InjuryType = request.Form(&quot;InjuryType&quot;)


'we need to do a select statement to retrieve to primary key for the driver's dept.
thissql = &quot;SELECT * FROM tblDept where tblDept.DeptID = &quot;&DriverDept&&quot;&quot;
set depSet = safetyDB.Execute(thissql)
If Not depSet.Eof then
DeptID = depSet(&quot;DeptID&quot;)
End If
depSet.close
set depSet = nothing

'Now we have everything lets create a record in the tblAccidentMain then retrieve the AccidentID
SafetyDB.Execute = &quot;INSERT INTO AccidentMain (DeptID, Loc_Desc, FactorsDesc, CollisionDesc, WeatherDesc,InjuryDesc, AccidentDate,TimeOfAccident,TimeOfAccidentAMPM,AccidentDesc,atFault,TestType,Result,DrugTest) VALUES (&quot;DriverDept&quot;, '&quot;&LocationDesc&&quot;', '&quot;&AccidentFactor&&quot;', '&quot;&AccidentCollision&&quot;', '&quot;&AccidentWeather&&quot;', '&quot;&InjuryType&&quot;', '&quot;&AccidentDate&&quot;', '&quot;&TimeOfAccident&&quot;', '&quot;&TimeOfAccidentAMPM&&quot;', '&quot;&AccidentDesc&&quot;' ,'&quot;&atFault&&quot;', '&quot;&TestType&&quot;', '&quot;&Result&&quot;', '&quot;&DrugTest&&quot;')&quot;
sqltext = &quot;SELECT AccidentMain.AccidentID FROM AccidentMain ORDER BY AccidentID DESC&quot;
set Accidentset = safetyDB.Execute(sqltext)
if not Accidentset.eof then
AccidentID = Accidentset(0)
end if

But I just can't get beyond this error message:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]
Line 40: Incorrect syntax near '='

which is here:
set depSet = safetyDB.Execute(thissql

Any help resolving this would be greatly appreciated.
 
Is your form method POST?

Look at your HTML that creates the first form, are the ID values showing in the OPTION tags?

On your second page, try this:

DriverDept = request.form(&quot;DriverDept&quot;)
response.write DriverDept
response.end

Is a value displayed?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
Your &quot;DriverDept&quot; option tags need to have a name, so
Code:
    <option value=&quot;<%=DeptSet(0)%>&quot;><%=DeptSet(1)%></option>
becomes
Code:
    <option name=&quot;DriverDept&quot; value=&quot;<%=DeptSet(0)%>&quot;><%=DeptSet(1)%></option>
 
Genimuse, I think you might be mistaken - OPTION tags do not get names, only values. Siena's code to create the options looks fine.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
mwolf00, you are right, option tags do not get names.
I did however, give it a name as the code below suggests.
your other question, I did response.write and response.end and no, no value is passed to it.
<TR>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Department</B>
</TD>
<td><select name=&quot;Driverdept&quot;>
<%
sql = &quot;SELECT tblDept.DeptID, tblDept.DeptName FROM tblDept &quot;
set deptset = safetyDB.Execute(sql)
While not DeptSet.EOF
%>
<option value=&quot;<%=DeptSet(0)%>&quot;><%=DeptSet(1)%></option>
<%
DeptSet.MoveNext
wend
%>
</select>
</td>
</TR>
 
Something is wrong on the first page then

Does the HTML on the first page look ok?

Do you have more than one field called &quot;DriverDept&quot;?

Are you POSTing the form?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
I hate to dump codes but here it is:
<%@ Language=VBScript%>

<%Response.buffer=true%>

<%Response.Expires = 0%>

<HEAD>
<LINK REL=STYLESHEET TYPE=&quot;text/css&quot; HREF=&quot;af_styles.css&quot;>
<TITLE>Accident Report</TITLE>
</HEAD>


<CENTER>
<BODY BGCOLOR=&quot;steelBLUE&quot;>
<%
set safetyDB = Server.CreateObject(&quot;ADODB.Connection&quot;)
safetyDB.Open &quot;dsn=safety&quot;
%>

<font class=&quot;ArialNarrow12&quot; COLOR=&quot;khaki&quot;><b>Accident Tracking - Driver Information</b></font>
    
<font class=&quot;Arial8&quot; COLOR=&quot;khaki&quot;>
<B>Welcome,  <font color=&quot;khaki&quot;><B>
<%=Session(&quot;fname&quot;)%>  
<%=Session(&quot;lname&quot;)%>  
</B></font>   
Date: <%=date()%>    Time: <%=Time()%></B></font>

<FORM ACTION=&quot;vehicle.asp&quot; method=get>
<TABLE WIDTH=98% BORDER=0 BGCOLOR=&quot;SILVER&quot; CELLPADDING=2 CELLSPACING=0 >
<TR>
<TD ALIGN=CENTER VALIGN=TOP>
<TABLE>

<TR>
<TD ALIGN=LEFT> <B><FONT CLASS='Arial10'>
Employee Name<B>
</TD>
<TD ALIGN=LEFT>
<select name=&quot;EName&quot;>
<%
sql = &quot;SELECT tblEmp.EmpID, tblEmp.fullName FROM tblEmp &quot;
set rs = safetyDB.Execute(sql)
While not rs.EOF
%>
<OPTION value=&quot;<%=rs(0)%>&quot;><%=rs(1)%></OPTION>
<%
rs.MoveNext
wend
rs.close
set rs=nothing
%>
</select>
</TD>
</TR>

<TR>
<TD ALIGN=LEFT><FONT CLASS='Arial10'><B>
Driver's Lic. Number
</TD>
<TD ALIGN=LEFT><FONT CLASS='Arial10'>
<INPUT TYPE='TEXT' NAME='DlicNumber' VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Street Address
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='STREET_ADDRESS' VALUE=&quot;<%=address %>&quot; >

</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
City
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='CITY' VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
State
</TD>
<TD>
<INPUT TYPE='TEXT' NAME='STATE' VALUE=&quot; &quot; >

</TD>
</TR>


<TR>
<TD><FONT CLASS='Arial10' ><B>
Zip Code
</TD>
<TD>

<INPUT TYPE='TEXT' NAME='ZIP_CODE' VALUE=&quot;&quot; >

</TD>
</TR>


<TR>
<TD><FONT CLASS='Arial10' ><B>
Home Phone
</TD>
<TD>

<INPUT TYPE='TEXT' NAME='HOME_PHONE' VALUE=&quot;&quot; >

</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Work/Cell
</TD>
<TD>

<INPUT TYPE='TEXT' NAME='CELL_PHONE' VALUE=&quot;&quot; >

</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Email
</TD>
<TD>

<INPUT TYPE='TEXT' NAME='WORK_EMAIL' VALUE=&quot;&quot; >

</TD>
</TR>

</TABLE>
</TD>

<TD VALIGN=&quot;top&quot; ALIGN=CENTER >
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=4 BORDERCOLOR=&quot;YELLOW&quot; >
<TR>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Department</B>
</TD>
<td><select name=&quot;Driverdept&quot;>
<%
sql = &quot;SELECT tblDept.DeptID, tblDept.DeptName FROM tblDept &quot;
set deptset = safetyDB.Execute(sql)
While not DeptSet.EOF
%>
<option value=&quot;<%=DeptSet(0)%>&quot;><%=DeptSet(1)%></option>
<%
DeptSet.MoveNext
wend
%>
</select>
</td>
</TR>

<TR>
<TD align=left>
<FONT CLASS='Arial10' COLOR='darkred'><B> Gender</B>
<TD> <SELECT name=&quot;Gender&quot; SIZE=1>
<OPTION value=&quot;Male&quot;>Male</OPTION>
<OPTION value=&quot;Female&quot;>Female</OPTION>
</SELECT>
</TD>
</TR>

<TR COLSPAN=2>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Age </B>
</TD>
<TD>
<SELECT NAME='Age' SIZE=1>
<OPTION value=&quot;15&quot;>15</OPTION>
<OPTION value=&quot;16&quot;>16</OPTION>
<OPTION value=&quot;17&quot;>17</OPTION>
<OPTION value=&quot;18&quot;>18</OPTION>
<OPTION value=&quot;19&quot;>19</OPTION>
<OPTION value=&quot;20&quot;>20</OPTION>
<OPTION value=&quot;21&quot;>21</OPTION>
<OPTION value=&quot;22&quot;>22</OPTION>
<OPTION value=&quot;23&quot;>23</OPTION>
<OPTION value=&quot;24&quot;>24</OPTION>
<OPTION value=&quot;25&quot;>25</OPTION>
<OPTION value=&quot;26&quot;>26</OPTION>
<OPTION value=&quot;27&quot;>27</OPTION>
<OPTION value=&quot;28&quot;>28</OPTION>
<OPTION value=&quot;29&quot;>29</OPTION>
<OPTION value=&quot;30&quot;>30</OPTION>
<OPTION value=&quot;31&quot;>31</OPTION>
<OPTION value=&quot;32&quot;>32</OPTION>
<OPTION value=&quot;33&quot;>33</OPTION>
<OPTION value=&quot;34&quot;>34</OPTION>
<OPTION value=&quot;35&quot;>35</OPTION>
<OPTION value=&quot;36&quot;>36</OPTION>
<OPTION value=&quot;37&quot;>37</OPTION>
<OPTION value=&quot;38&quot;>38</OPTION>
<OPTION value=&quot;39&quot;>39</OPTION>
<OPTION value=&quot;40&quot;>40</OPTION>
<OPTION value=&quot;41&quot;>41</OPTION>
<OPTION value=&quot;42&quot;>42</OPTION>
<OPTION value=&quot;43&quot;>43</OPTION>
<OPTION value=&quot;44&quot;>44</OPTION>
<OPTION value=&quot;45&quot;>45</OPTION>
<OPTION value=&quot;46&quot;>46</OPTION>
<OPTION value=&quot;47&quot;>47</OPTION>
<OPTION value=&quot;48&quot;>48</OPTION>
<OPTION value=&quot;49&quot;>49</OPTION>
<OPTION value=&quot;50&quot;>50</OPTION>
<OPTION value=&quot;51&quot;>51</OPTION>
<OPTION value=&quot;52&quot;>52</OPTION>
<OPTION value=&quot;53&quot;>53</OPTION>
<OPTION value=&quot;54&quot;>54</OPTION>
<OPTION value=&quot;55&quot;>55</OPTION>
<OPTION value=&quot;56&quot;>56</OPTION>
<OPTION value=&quot;57&quot;>57</OPTION>
<OPTION value=&quot;58&quot;>58</OPTION>
<OPTION value=&quot;59&quot;>59</OPTION>
<OPTION value=&quot;60&quot;>60</OPTION>
<OPTION value=&quot;61&quot;>61</OPTION>
<OPTION value=&quot;62&quot;>62</OPTION>
<OPTION value=&quot;63&quot;>63</OPTION>
<OPTION value=&quot;64&quot;>64</OPTION>
<OPTION value=&quot;65&quot;>65</OPTION>
<OPTION value=&quot;66&quot;>66</OPTION>
<OPTION value=&quot;67&quot;>67</OPTION>
<OPTION value=&quot;68&quot;>68</OPTION>
<OPTION value=&quot;69&quot;>69</OPTION>
<OPTION value=&quot;70&quot;>70</OPTION>
<OPTION value=&quot;71&quot;>71</OPTION>
<OPTION value=&quot;72&quot;>72</OPTION>
<OPTION value=&quot;73&quot;>73</OPTION>
<OPTION value=&quot;74&quot;>74</OPTION>
<OPTION value=&quot;75&quot;>75</OPTION>
<OPTION value=&quot;76&quot;>76</OPTION>
<OPTION value=&quot;77&quot;>77</OPTION>
<OPTION value=&quot;78&quot;>78</OPTION>
<OPTION value=&quot;79&quot;>79</OPTION>
<OPTION value=&quot;80&quot;>80</OPTION>
</TD>
</TR>
<tr>
<td><FONT CLASS='Arial10' COLOR='darkred'><B>Was a Drug test done?</B></FONT></td>
<td><select name=&quot;Drug&quot;>
<option value=&quot;Yes&quot;>Yes</option>
<option value=&quot;No&quot;>No</option>
<option value=&quot;Refused&quot;>Refused</option>
</select>
</td>
</tr>

<tr>
<td><FONT CLASS='Arial10' COLOR='darkred'><B>What type of test was done?</B></FONT></td>
<td><select name=&quot;TestType&quot;>
<option value=&quot;Not Applicable&quot;>Not Applicable</option>
<option value=&quot;Blood&quot;>Blood</option>
<option value=&quot;Breath&quot;>Breath</option>
<option value=&quot;Urine&quot;>Urine</option>
<option value=&quot;Other&quot;>Other</option>
</select></td>
</tr>
<tr>
<td><FONT CLASS='Arial10' COLOR='darkred'><B>What Was The Result?</B></FONT></td>
<td><select name=&quot;Result&quot;>
<option value=&quot;Not Applicable&quot;>Not Applicable</option>
<option value=&quot;Positive&quot;>Positive</option>
<option value=&quot;Negative&quot;>Negative</option>
<option value=&quot;Inconclusive&quot;>Inconclusive</option>
</select></td>
</tr>
<tr>
<td><FONT CLASS='Arial10' COLOR='darkred'><B>Was this driver at fault?</B></FONT></td>
<td><select name=&quot;AtFault&quot;>
<option value=&quot;Not Applicable&quot;>Not Applicable</option>
<option value=&quot;Yes&quot;>Yes</option>
<option value=&quot;No&quot;>No</option>
</select></td>
</tr>
<tr>
<td><FONT CLASS='Arial10' COLOR='darkred'><B>What was the drivers condition?</B></FONT></td>
<td><select name=&quot;Condition&quot;>
<option value=&quot;Not Drinking&quot;>Not Drinking</option>
<option value=&quot;Not Known If U.I.&quot;>Not Known If U.I.</option>
<option value=&quot;Not Impaired&quot;>Not Impaired</option>
<option value=&quot;U.I. Alcohol&quot;>U.I. Alcohol</option>
<option value=&quot;U.I Drugs&quot;>U.I. Drugs</option>
<option value=&quot;U.I. Alchol & Drugs&quot;>U.I. Alchol & Drugs</option>
<option value=&quot;Physical Impairement&quot;>Physical Impairement</option>
<option value=&quot;Apparently Fell Asleep&quot;>Apparently Fell Asleep</option>
</select></td>
</tr>


<tr>
<td width=&quot;21%&quot;><B><FONT CLASS='Arial10' COLOR='darkred'><B>Please select Injury type:</FONT></B></td>
<td width=&quot;29%&quot;> <select name=&quot;InjuryType&quot;>
<option value=&quot;Not Injured&quot;>Not Injured</option>
<option value=&quot;Killed&quot;>Killed</option>
<option value=&quot;Serious&quot;>Serious</option>
<option value=&quot;Visible&quot;>Visible</option>
<option value=&quot;Complaint&quot;>Complaint</option>
</select>
</td>
</tr>
</TABLE>
</TD>
</TR>

<TR>
<TD bgcolor=khaki COLSPAN=2 BGCOLOR=WHITE ALIGN=CENTER>
<INPUT TYPE=submit VALUE=&quot;Continue&quot;>
</TD>
</TR>

</TABLE>
</FORM>
</CENTER>
<%
safetyDB.close
set safteyDB = nothing
%>

</BODY>

 
as mwolf00 already asked
<FORM ACTION=&quot;vehicle.asp&quot; method=get>

is that suppose to be POST????

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
D'oh! Sorry! I really shouldn't post within 10 minutes of waking up!
 
shoot!
Yea, you are right Genimuse and onpnt an mwof00!
I apologize to all of you!
 
Ok, now I've been up for 30 minutes, let's see if it makes any difference.

It appears to my still sleep-addled brain that your SQL around Driverdept is missing two ampersands, so this:
Code:
    ... VALUES &quot;DriverDept&quot;, '&quot;&LocationDesc&&quot;', ...
becomes this:
Code:
    ... VALUES (&quot;&DriverDept&&quot;, '&quot;&LocationDesc&&quot;', ...
 
no apologies!

mwolf00 nice catch!

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Genimuse,

Since siena has server-side delimiters (<% %>) in her code, she doesn't need the ampersands...

<%
While not DeptSet.EOF
%>
<option value=&quot;<%=DeptSet(0)%>&quot;><%=DeptSet(1)%></option>
<%
DeptSet.MoveNext
wend
%>


the bold line is the same as...

response.write &quot;<option value=&quot;&quot;&quot;
response.write DeptSet(0)
response.write &quot;&quot;&quot;>&quot;
response.write DeptSet(1)
response.write &quot;</option>&quot;

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
mwolf00, I think Genimuse was refering to the other page where I am inserting into AccidentMain(DeptID)values(&quot;&driver&&quot;)
Genimuse, don't worry everything is working now.
I thank you all again!
 
ooppss - sorry Genimuse [hammer]

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top