SQL bracketing error

Matt Brown

Registered User.
Local time
Today, 11:23
Joined
Jun 5, 2000
Messages
120
Can anyone see a problem with this sql syntax:

Code:
SQL = "SELECT [newcust.CUST_REF], [newcust.SUB], [newcust.ADDR1], [newcust.ADDR2], " & _
" [newcust.ADDR3], [newcust.ADDR4], [newcust.PC], [newcust.country], [newcust.REP], " & _
" [newcust.ISE_CODE], [custgen.MFTR_CAT] , [newcust.CUR_CODE], [newcust.NAME] " & _
" FROM [custgen] INNER JOIN [newcust] ON [custgen.CONS_AC_NO] = [newcust.CONS_AC_NO] " & _
" where customerNo = '" & Trim(Me.CustomerNo) & "';"

It returns an "Invalid bracketing of name [custgen.CONS_AC_NO]" error.

cheers

Matt
 
ALL the bracketing is invalid. Each object should be enclosed within brackets:

i.e.

SELECT [newcust].[CUST_REF], [newcust].[SUB] etc.
 
Thanks.

Didn't release each object had to be enclosed in brackets.

Mucho gracious

Matt
 
They don't always need to be. Any fields that have spaces, use underscores, special characters, or reserved words should be enclosed within brackets. Also, if there's only one table, you only need to mention it in the FROM clause
 
How would i write the record sets out:

Would they be:

cName = rs1![newcust].[Name]

or

cName = rs1!newcust.Name

thanks

Matt
 
As rs should already be defined as a table or query already that's not necessary.

The best is to use:

Code:
cName = rs.Fields("Name")


Forget about the ! (unless referencing from a query) forever...
 
Thankyou for your time and wisdom on this.

This is now working for me.

thanks again

Matt :)
 

Users who are viewing this thread

Back
Top Bottom