Dear all,
I am getting this error and its not getting resolved at all:
Syntax error (missing operator) in query expression 'OrderNo='.
On line:RS.Open query, objConn

This is my code where i am pulling records on the orderno and after i have pulled the records ,i am trying to insert them in another table on clicking Submit button.I am getting Orderno from the previous page and thats getting displayed properly.Dont know why that error is commig up all the time.Here is the code:

<html>
<%@ Language="VBScript" %>
<html>
<head><title>Agent information about a client</title>
</head>
<body>
<span style="background-color: #00FFFF">
<%
Dim objConn ,RS, data_source,query,ID,querymembers,strSQL
ID=request.querystring("ID")
Session("ID") = ID
Response.Write ID
Set objConn = Server.CreateObject("ADODB.Connection")
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("db1.mdb")
objConn.Open data_source
Set RS=Server.CreateObject("ADODB.Recordset")
Set RS1=Server.CreateObject("ADODB.Recordset")
query="Select * from tblorder where OrderNo= " & Session("ID")
Response.write query
RS.Open query, objConn
querymembers="SELECT members.TitleDocuments,members.NameProcessor1,memb ers.NameProcessor2 FROM members INNER JOIN tblorder ON members.CompanyName = tblorder.CompanyName"
RS1.Open querymembers,objConn
if Request.form("submit")<>"" then
strSQL = "INSERT INTO Status ([CompanyName],[Lender],[OrderProcessor],[ClosingDate],[FeeType],[TimeofClosing],[CustomerName],[StreetAddress],[State],[Phone1],[Status],[OrderNo],[OrderProcessor2],[OrderDate],[Fee],[DocDelivery],[FileNumber],[City],[ZipCode],[Phone2],[Notes],[AgentName]) VALUES " & _
"('" & fixQuotes(Request.Form("CompanyName")) & "','" & _
fixQuotes(Request.Form("Lender")) & "','"&_
fixQuotes(Request.Form("NameProcessor1")) & "','"&_
fixQuotes(Request.Form("ClosingDate"))&"','"&_
fixQuotes(Request.Form("FeeType"))&"','"&_
fixQuotes(Request.Form("ClosingTime"))&"','"&_
fixQuotes(Request.Form("BorrowerName"))&"','"&_
fixQuotes(Request.Form("ClosingAddress"))&"','"&_
fixQuotes(Request.Form("State"))&"','"&_
fixQuotes(Request.Form("WorkNumber"))&"','"&_
fixQuotes(Request.Form("Status"))&"','"&_
fixQuotes(Request.Form("OrderNo"))&"','"&_
fixQuotes(Request.Form("NameProcessor2"))&"','"&_
fixQuotes(Request.Form("OrderDate"))&"','"&_
fixQuotes(Request.Form("Fee"))&"','"&_
fixQuotes(Request.Form("TitleDocuments"))&"','"&_
fixQuotes(Request.Form("FileNumber"))&"','"&_
fixQuotes(Request.Form("City"))&"','"&_
fixQuotes(Request.Form("Zip"))&"','"&_
fixQuotes(Request.Form("HomeNumber"))&"','"&_
fixQuotes(Request.Form("Notes"))&"')"','"&_
fixQuotes(Request.Form("AgentName"))&"')"
Response.write strSQL
objConn.Execute(strSQL)
end if
Function fixQuotes(strData)
fixQuotes = Replace(strData,"'","''")
End Function
%>

</span>

<div align='center'>
<table width="370" border="0" cellspacing="0" cellpadding="0" align="center">
<tr align="left" valign="top">
<td>
<div align="center">
<p><u><b><font size="5" color="#008000">Order Submittal Form</font></b></u></p>
<!-- start the html form -->
<form method="post" action="infoviewagentver212.asp" name="form">
</td>
<table width="100%" border="0">
<tr>
<td width="7%">Company Name:
</td>
<td colspan="6">
<input type="text" disabled name="CompanyName" value="<%= RS("CompanyName")%>" size='30'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
<tr>
<td width="7%" height="32">Lender</td>
<td colspan="4" height="32">
<input type="text" disabled name="Lender" value="<%= RS("Lender")%>" size='30'>
</td>
<td height="32">
Order Number</td>
<td height="32">
<input type="text" name="OrderNo" value="<%= RS("OrderNo")%>" size='30'></td>
</tr>
<tr>
<td>
Order Processor</td>
<td width="27%" colspan="2">
<input type="text" name="NameProcessor1" value="<%= RS1("NameProcessor1")%>" size='30'></td>
<td width="14%" colspan="3">
Alternative Order Processor</td>
<td width="29%">
<input type="text" name="NameProcessor2" value="<%= RS1("NameProcessor2")%>" size='30'></td>
</tr>
<tr>
<td height="32">
Closing Date</td>
<td height="32" colspan="2">
<input type="text" name="ClosingDate" value="<%= RS("ClosingDate")%>" size='30'></td>
<td height="32" colspan="3">
Order Date</td>
<td height="32">
<input type="text" name="TodaysDate" value="todays date" size='30'></td>
</tr>
<tr>
<td>
Fee Type</td>
<td colspan="2">
<select size="1" name="FeeType">
<option>Emailed Documents</option>
<option>Overnight Fedex</option>
</select></td>
<td colspan="3">
Fee</td>
<td>
<input type="text" name="Fee" size='30'></td>
</tr>
<tr>
<td>
Time</td>
<td colspan="2">
<input type="text" name="ClosingTime" value="<%= RS("ClosingTime")%>" size='30'></td>
<td colspan="3">
Doc Delivery</td>
<td>
<input type="text" name="TitleDocuments" value="<%= RS1("TitleDocuments")%>" size='30'></td>
</tr>
<tr>
<td>
Customer Name</td>
<td colspan="2">
<input type="text" name="BorrowerName" value="<%= RS("BorrowerName")%>" size='30'></td>
<td colspan="3">
File Number</td>
<td>
<input type="text" name="FileNumber" value="<%= RS("FileNumber")%>" size='30'></td>
</tr>
<tr>
<td>
Street Address</td>
<td colspan="2">
<input type="text" name="ClosingAddress" value="<%= RS("ClosingAddress")%>" size='30'></td>
<td colspan="3">
City</td>
<td>
<input type="text" name="City" value="<%= RS("City")%>" size='30'></td>
</tr>
<tr>
<td>
State
</td>
<td colspan="2">
<input type="text" name="State" value="<%= RS("State")%>" size='30'></td>
<td colspan="3">
Zip Code</td>
<td>
<input type="text" name="Zip" value="<%= RS("Zip")%>" size='30'></td>
</tr>
<tr>
<td>
Phone1</td>
<td colspan="2">
<input type="text" name="WorkNumber" value="<%= RS("WorkNumber")%>" size='30'></td>
<td colspan="3">
Phone2
</td>
<td>
<input type="text" name="HomeNumber" value="<%= RS("HomeNumber")%>" size='30'></td>
</tr>
<tr>
<td>
Status</td>
<td colspan="2">
<select size="1" name="Status">
<option>Cancel</option>
<option>Confimed with borrower</option>
<option>Lender Received</option>
<option>H/T Received</option>
<option>Lender Printed</option>
<option>H/T Printed</option>
</select></td>
<td colspan="3">
Agent</td>
<td>
<input type="text" disabled name="AgentName" value="<%= RS("AgentName")%>" size='30'></td>
</tr>
<tr>
<td>
NOTES:</td>
<td width="44%">
<textarea rows="12" name="Notes" cols="52"></textarea></td>
<td colspan="2">
&nbsp;</td>
<td colspan="3">
&nbsp;</td>
</tr>
<tr>
<td colspan="7">
&nbsp;</td>
</tr>
<tr>
<td colspan="7">
<p align="center">
<input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td colspan="7">
&nbsp;</td>
</tr>
<tr>
<td colspan="7">
&nbsp;</td>
</tr>
<tr>
<td colspan="7">
&nbsp;</td>
</tr>
<td colspan="7">
<div align="center">
&nbsp;</div>
</td>
</tr>
<tr>
<td colspan="7">&nbsp;</td>
</tr>
</table>
<br>
<br>
</form>
<!-- end the html form -->
</div>
</td>
</tr>
</table>
</div>
<%
'close the connection and recordset objects
RS.Close
Set RS=Nothing
objconn.Close
Set objconn=Nothing
%>
</body>
</html>

If the OrderNo db column is an integer field you shouldn't use single quotes. Single quotes implies string value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.