I am using variables in a SQL String to build an Access Query - my issue is (I Think) the fact that when I do a Debug.Print sql2 this is the output that I get
Code:
SELECT DISTINCT [_SpreadsheetImport].' & locID & ', ConcatRelated('& userID & ','[_SpreadsheetImport]',' & locID & ' =' & locID & ') AS ItemCode,ConcatRelated('& saleCT &','[_SpreadsheetImport]',' & locID & ' =' & locID & ') AS ItemQty INTO [TotalInfo] FROM [_SpreadsheetImport]
So I am actually printing the variable name, and not the value. This is the syntax that I have, should I Have used double quotes instead of single quotes around the variables in the string? What is the proper way to escape these characters? Despite the name, they are all string variables
Code:
Dim sql2 As String
sql2 = "SELECT DISTINCT [_SpreadsheetImport].' & locID & ', ConcatRelated('& userID & ','[_SpreadsheetImport]',' & locID & ' =' & locID & ') AS ItemCode,ConcatRelated('& saleCT &','[_SpreadsheetImport]',' & locID & ' =' & locID & ') AS ItemQty INTO [TotalInfo] FROM [_SpreadsheetImport]"
Debug.Print sql2