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

SQL statement not working

Status
Not open for further replies.

phiberdelic

Technical User
Oct 26, 2002
6
US
I need help with this statement. I am getting "Expected end of statement" at ") AND (PONumber BETWEEN "...please advise as to what I am doing wrong here I am not proficient in SQL statements and am just winging it.

If chkDateRange.Value <> 0 And chkPORange.Value <> 0 And chkLocation.Value <> 0 Then
rsRecordset.Open &quot;INSERT INTO tblDataHold(Vendor), tblDataHold(PONumber),&quot; & _
&quot; tblDataHold(ReceiptDate), tblDataHold(Location) SELECT Vendor, PONumber,&quot; & _
&quot; ReceiptDate, Location FROM ReceivingsHeader WHERE ((Vendor=&quot; & cmbVendors.Value & _
&quot;) AND (Location=&quot; & lstLocation.value &quot;) AND (PONumber BETWEEN &quot; & txtFromPO.value &quot; AND &quot; & txtToPO.value &quot;)And (ReceiptDate &quot; & _
&quot;between &quot; & txtStartDate.value &quot; and &quot; & txtEndDate.value &quot;))&quot; & _
, cnCurrent, adOpenDynamic, adLockOptimistic;
End If
 
You missed several '&' between variables and strings, for example:
Code:
&quot;) AND (Location=&quot; & lstLocation.value
&
Code:
 &quot;) AND (PONumber BETWEEN &quot;

See if this compiles:

rsRecordset.Open &quot;INSERT INTO tblDataHold(Vendor), tblDataHold(PONumber),&quot; & _
&quot; tblDataHold(ReceiptDate), tblDataHold(Location) SELECT Vendor, PONumber,&quot; & _
&quot; ReceiptDate, Location FROM ReceivingsHeader WHERE ((Vendor=&quot; & cmbVendors.Value & _
&quot;) AND (Location=&quot; & lstLocation.Value & &quot;) AND (PONumber BETWEEN &quot; & txtFromPO.Value & &quot; AND &quot; & txtToPO.Value & &quot;) And (ReceiptDate &quot; & _
&quot;between &quot; & txtStartDate.Value & &quot; and &quot; & txtEndDate.Value & &quot;));&quot;, cnCurrent, adOpenDynamic, adLockOptimistic
VBSlammer
redinvader3walking.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top