• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Error: Concatenate in SELECT statements

inddon

Member
Hello There,

I am getting an error in the below SELECT statement. I am trying to concatenate columns

Could you please advise, how to resolve this?

Thanks & regards
Don


Runtime error 13: Type Mismatch
Code:
  strQuery = "SELECT [Party Name] & " - " & [Country] & " - " & [City], [Pick-up] & " - " & [Mode] & " - " & [Empty Depot], [Local THC Rotterdam], [Gross Tonnage], [Terminal], [Transport], [WHS xdock], [FTL] FROM [Sheet1$A:R] WHERE [Party Name]='" & CBuyerName & _
  "' AND  [VAT Number]='" & CBuyerVATNumber & "';"
 
Hi,

SQL not recognise the "&" hence it is giving an error try using "+" instead "&".


Eg:

strquery = "Select number + name as numname from table_name"


Regards
Abdul Matheen
 
Hi,

The query is not in a proper format

What are you trying to achieve with this query


Hello Sathish,
Thank you for your reply.

Instead of showing Party name, Country & City in three columns, I would like to the SQL SELECT to show it in one column.

eg.

Existing Look (Showing in 3 columns):
Samsung Netherlands Rotterdam

New look (Showing in 3 columns in 1 coulmn, '-' separator): Samsung - Netherlands - Rotterdam

Regards
Don
 
You cannot imply this on sql statement

It should be done after the data is retrieved


Hello Sathish,

Thank you for your reply.

I did it after the data is retrieved, but it gives an error message. I guess it was type mismatch. Therefore I brought it the SELECT statment

regards
Don
 
Back
Top