Forum Discussion
CJDataBI
Sep 06, 2023Copper Contributor
New to Sql/VBA - How to concatenate two fields
Hi, I've been using access for a long time, but have always used Macro builder etc..very little experience with SQL. I had someone write a query for me that updates data in a table - (qry_Create...
Tom_van_Stiphout
Sep 06, 2023Iron Contributor
strSQL = "INSERT INTO qry_CreatePriceAddTemplate SELECT [tbl_Contract ID].[Indirect Contract], [tbl_Contract ID].[Alt Contract], "
strSQL = strSQL & "[tbl_Contract ID].[Contract Description], tbl_NDCXREF.[NDC Full], "
strSQL = strSQL & "tbl_NDCXREF.[MATERIAL DESCRIPTION], '' AS Price, '' AS Effective, "
strSQL = strSQL & Chr(34) & "12/31/9999" & Chr(34) & " AS [End Date]", [Indirect Contract]&[NDC Full] AS XREFID
strSQL = strSQL & " FROM tbl_NDCXREF, [tbl_Contract ID]"
strSQL = strSQL & " WHERE tbl_NDCXREF.[MATERIAL DESCRIPTION] IN (" & strSelectedProduct & ")"
strSQL = strSQL & " And [tbl_Contract ID].[Contract Description] IN (" & strSelectedContractDesc & ")"
strSQL = strSQL & " GROUP BY [tbl_Contract ID].[Indirect Contract], [tbl_Contract ID].[Alt Contract], "
strSQL = strSQL & "[tbl_Contract ID].[Contract Description], tbl_NDCXREF.[NDC Full], "
strSQL = strSQL & "tbl_NDCXREF.[MATERIAL DESCRIPTION], ''," & Chr(34) & "12/31/9999" & Chr(34) & ", '', [Indirect Contract]&[NDC Full]"
strSQL = strSQL & "[tbl_Contract ID].[Contract Description], tbl_NDCXREF.[NDC Full], "
strSQL = strSQL & "tbl_NDCXREF.[MATERIAL DESCRIPTION], '' AS Price, '' AS Effective, "
strSQL = strSQL & Chr(34) & "12/31/9999" & Chr(34) & " AS [End Date]", [Indirect Contract]&[NDC Full] AS XREFID
strSQL = strSQL & " FROM tbl_NDCXREF, [tbl_Contract ID]"
strSQL = strSQL & " WHERE tbl_NDCXREF.[MATERIAL DESCRIPTION] IN (" & strSelectedProduct & ")"
strSQL = strSQL & " And [tbl_Contract ID].[Contract Description] IN (" & strSelectedContractDesc & ")"
strSQL = strSQL & " GROUP BY [tbl_Contract ID].[Indirect Contract], [tbl_Contract ID].[Alt Contract], "
strSQL = strSQL & "[tbl_Contract ID].[Contract Description], tbl_NDCXREF.[NDC Full], "
strSQL = strSQL & "tbl_NDCXREF.[MATERIAL DESCRIPTION], ''," & Chr(34) & "12/31/9999" & Chr(34) & ", '', [Indirect Contract]&[NDC Full]"