SQL Select Statement-Space in Column Name (1 Viewer)

ECEstudent

Registered User.
Local time
, 19:40
Joined
Jun 12, 2013
Messages
153
Does anyone know what's wrong with this line of code?


Code:
strSQL = ("INSERT INTO " & strTable & " Select c.OrderNumber, c.Item, c.RepId, p.ProductNbr, p.Name, [tbl_LBP_Sales Location Num].[Rep Region Code] FROM CalculateTotal c, dbo_PartNew p, [tbl_LBP_Sales Location Num] WHERE ([Structure] like '*" & u & "*') AND ([ProductNbr] = '" & txtPartNumber & "')")
 
CurrentDb.Execute strSQL

It keeps giving me this error and I don't know why?...

I tried replacing the brackets around Rep Region Code with quotation marks as well as these things `` but kept getting the same error...
 

Attachments

  • error.png
    error.png
    8 KB · Views: 109

ECEstudent

Registered User.
Local time
, 19:40
Joined
Jun 12, 2013
Messages
153
Figured it out :) Turns out I had to include the brackets in this line as well!

Code:
CurrentDb.Execute "CREATE TABLE tblTest2 " _
& "(RepId CHAR, OrderNumber CHAR, Item CHAR, ProductNbr CHAR, Name CHAR, [Rep Region Code] CHAR);" 'Rebuild tblTest2 for use
 

Users who are viewing this thread

Top Bottom