Search code examples
sqlms-accesslistcontrol

Type mismatch error when concatenating fileds and assigning to Row source in Access


I have a form with list control named lstCustomer. I am passing rowsource method a string as shown below

me.lstCustomer.RowSource = lstSQL

The lstSQL is being specified before assigning to rowSource method.

lstSQL = "SELECT FullName, City & " - " & Region AS Location FROM tblContact ORDER BY FullName;"

This is produicing an error Type Mismatch

When I am not using concatenated column, I am not getting this error. I tried the below code (this does not produces the error)

lstSQL = "SELECT FullName, City, Region FROM tblContact ORDER BY FullName;"

I want to show city and region in a single column. Please point out my mistake. Thanks in advance.


Solution

  • Please use single quotes ' instead of " in the query:

    SELECT FullName, City & ' - ' & Region AS Location 
    FROM tblContact ORDER BY FullName;