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

Syntax error 1

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
I want to insert into the table OrdersPaid those records from the table orders, where the field paid is set to true
but i get the message too few parameters. can you help ?

Dim StrSQL As String
StrSQL = "INSERT INTO OrdersPaid (OrderID, paid) " & _
"SELECT orderid,paid FROM orders " & _
"WHERE orderspaid.orderid = orders.orderid and orders.paid = true "

CurrentDb.Execute StrSQL

 
The way that query is sketched, it seems that you would only insert Orders that already exist in OrdersPaid. i do not think you want to do this. I think you want to do something like this:

Code:
INSERT INTO OrdersPaid ( OrderID, paid )
SELECT orders.OrderID, orders.Paid
FROM orders
WHERE orders.OrderID Not In (Select OrderID From OrdersPaid) AND orders.Paid)="True"

Is that correct?
 
Carefully taking out the extra bracket first, of course :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top