Hi I'm having trouble with variables in an INSERT INTO string that I'm
executing in A97 to SQL Server 2k tables.
I can get the SQL command to work using values such as :
strSQL2 = "INSERT INTO tblEmployee "
strSQL2 = strSQL2 & "SELECT tblProducts.CostCentre, tblProducts.Class,
tblProducts.ProductGroup, 9016255 AS EmployID, tblProducts.Description,
tblProducts.Division, tblProducts.BusinessUnit, tblProducts.Category,
tblProducts.EmplDefault AS Allocation, tblProducts.Vis, Now() AS Modified,
CurrentLogin() AS ModifiedBy"
strSQL2 = strSQL2 & " FROM tblProducts"
strSQL2 = strSQL2 & " WHERE (((tblProducts.CostCentre)= 221) AND
((tblProducts.Vis)=True));"
But as soon as I replace 916255 with " & rst!EmployeeNumber & " it stops
working. EmployeeNumber is a field in a recordset and is active when this
query is executed.
Same with the cost centre 221
I can only guess I'm messing up the number of quotes around the variable. By
trial and error some appear to work but the data just isnt being inserted.
Am I doing something else wrong?.
TIA