HI,

I am trying to assign a person_id from application pass it on to excel , is my code correct? when I run it I get sql error saying " conversion failed when converting from character string to uniqueidentifier"
Thanks!

Sub Auto_open()

'Private Function GetPersonID$(ByVal person_id As String)

Dim person_id As String
'perosn_id = ("a.person_id")
'perosn_id = ("unique identifier")


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DSN=ngdevl;Description=NGDevl;UID=sa;:APP=Microsoft Office 2010;;DATABASE=NGDevl" _
, Destination:=Range("$A$30")).QueryTable

.CommandText = Array( _
" declare @person_id varchar(36) select user_name, password,a.Create_timestamp, security_answer,b.last_name,b.first_name from ngweb_bulk_enrollments a " _
, _
"INNER JOIN person b ON b.person_id = a.person_id where b.person_id = '" & person_id & "'")

.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False11
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query1"
.Refresh BackgroundQuery:=True
End With