Heya,
In VBA does anyone know how to use a variable in a SQL connection string?
We're aiming for active directory integrated login for SQL that works great, just hoping to prefill thei username field.
Code:
Sub connect() Dim cdb As DAO.Database, qdf As DAO.QueryDef
Set cdb = CurrentDb
Set qdf = cdb.CreateQueryDef("")
qdf.connect = "ODBC;" & _
"Driver={ODBC Driver 17 for SQL Server};" & _
"Server=*****.database.windows.net;" & _
"Database=BDC;" & _
"Trusted_Connection=no;" & _
"Authentication=ActiveDirectoryInteractive;" & _
"UId=& ""> #"" & TempVars!Email2 & ""#"";"
qdf.ReturnsRecords = False
qdf.Execute dbFailOnError
Set qdf = Nothing
Set cdb = Nothing
End Sub
Thanks everyone!