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!

Too few parameters 1

Status
Not open for further replies.

peljo

Technical User
Mar 3, 2006
91
BG
Can you help me ? I am having troubles with creating the second table order detailsTemp where i get the error Too few parmeters. My original tables are orders1 and order details1 and i want to make the tables ordersTemp and order detaistemo, .i suceed only with ordersTemp:

Dim strsql As String
Dim lngMaxOrderID As Long
lngMaxOrderID = DMax("[OrderID]", "orders1")
Dim StrOrders As String
Dim strOrderDetails As String


StrOrders = " SELECT orders1.* INTO ordersTemp FROM orders1 WHERE orders1.Suborder = -1 and orders1.orderid = " & lngMaxOrderID
CurrentDb.Execute StrOrders
CurrentDb.Execute "CREATE INDEX PrimaryKey ON OrdersTemp (OrderID) WITH PRIMARY"

strOrderDetails = " SELECT[order details1].orderid,[order details1].productid,[order details1].cartons,[order details1].quantity " & _
" INTO [Order DetailsTemp] FROM [order details1] INNER JOIN orders ON [order details1].OrderID = [orders].orderid WHERE orders1.Suborder = -1"
CurrentDb.Execute strOrderDetails
 
I think you just have a couple of misplaced spaces. Try this:

Code:
strOrderDetails = "SELECT [order details1].orderid, [order details1].productid, [order details1].cartons, [order details1].quantity " & _
" INTO [Order DetailsTemp] FROM [order details1] INNER JOIN orders ON [order details1].OrderID = [orders].orderid WHERE orders1.Suborder = -1"
CurrentDb.Execute strOrderDetails

I'd also recommend you do not include space characters in your table names - this is not generally considered good practice.

Ed Metcalfe.

Please do not feed the trolls.....
 
Double check the spelling of the fields names.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you for your replies. The error shows to the inner join:

strOrderDetails = "SELECT [order details1].orderid, [order details1].productid, [order details1].cartons, [order details1].quantity " & _
" INTO [Order DetailsTemp] FROM [order details1] INNER JOIN orders1 ON [order details1].OrderID = [orders].orderid WHERE orders1.Suborder = -1"
CurrentDb.Execute strOrderDetails
 
Replace this:
orders
with this:
orders1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 


Thank you for the reply.Before the replacement it shows to many parameters.After the replacement the error is syntax error in join operation.MAybe my syntax is wrong ?
 
strOrderDetails = "SELECT [order details1].orderid, [order details1].productid, [order details1].cartons, [order details1].quantity " & _
" INTO [Order DetailsTemp] FROM [order details1] INNER JOIN orders1 ON [order details1].OrderID = [orders1].orderid WHERE orders1.Suborder = -1"


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes, it helps ! Thank you !
 
Would yo help me with a further advice? I want to include the the value lngMaxOrderID which isn't used in the second SQL string, so I am finding my Order DetailsTemp with records for many other OrderIDs.
Therefore I tried to attach this value to the string, but then I get red letters which means that my sql is not right.


Dim lngMaxOrderID As Long
Dim StrOrders As String
Dim strOrderDetails As String
lngMaxOrderID = DMax("[OrderID]", "orders1")
StrOrders = " SELECT orders1.* INTO ordersTemp FROM orders1 WHERE orders1.Suborder = -1 and orders1.orderid = " & lngMaxOrderID
CurrentDb.Execute StrOrders

CurrentDb.Execute "CREATE INDEX PrimaryKey ON OrdersTemp (OrderID) WITH PRIMARY"

strOrderDetails = "SELECT [order details1].orderid, [order details1].productid, [order details1].cartons, [order details1].quantity " & _
" INTO [Order DetailsTemp] FROM [order details1] INNER JOIN orders1 ON [order details1].OrderID = [orders1].orderid WHERE orders1.Suborder = -1 and orders1.orderid = " & lngMaxOrderID"
CurrentDb.Execute strOrderDetails
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top