Syntax error

peljo

Registered User.
Local time
Today, 01:04
Joined
May 24, 2006
Messages
24
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.
Would yo uhelp me amend my second sql ?

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
 
Take out the last quote after lngMaxOrderID
 

Users who are viewing this thread

Back
Top Bottom