Syntax error

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

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
 
B

boblarson

For the benefit of others (because this question was answered on AWF for the
same poster):

As KeithG posted:

Take out the last quote after lngMaxOrderID

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.
 
P

peljo via AccessMonster.com

Thank you so much !
For the benefit of others (because this question was answered on AWF for the
same poster):

As KeithG posted:

Take out the last quote after lngMaxOrderID
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
[quoted text clipped - 20 lines]
orderid = " & lngMaxOrderID"
CurrentDb.Execute strOrderDetails
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Recordset within a recordset? 5
Delete query 1
Winfax from Access 0
Loop problem 4
Characters found at end of sql error-Repost 2
Connection String 2
SQL Troubles. 1
Another Autofill Question 0

Top