I need help on passing a "person_id" from the application into VBA code below, please help: Here is what I am using but not working because my argument is not correct.
Thanks!!
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
Sub Auto_open()
Dim person_id As Double
person_id = ""
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DSN=ngdevl;Description=NGDevl;UID=sa;pwd="";APP=Microsoft Office 2010;;DATABASE=NGDevl" _
, Destination:=Range("$A$30")).QueryTable
.CommandText = Array( _
" select user_name, password,* 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:=False
End With
Bookmarks