Sub Task()
Dim thisQT As QueryTable
Dim sqlstring As String
Dim connstring As String
Dim Strcode As String

    Strcode = Trim(InputBox("Please enter a Job #", "Task history"))
    
    sqlstring = "select distinct m.JobNumber , cast(m.ExpectedDate as DATE) 'Ship Date' ,m.CustLongName 'Customer'" & _
                 " from ArchiveJobHeader m  left join AuxiliaryInfoFile af (nolock) on af.jobnumber=m.jobnumber" & _
                 " where m.JobNumber = '" & Trim(Strcode) & "'" & _
                 " order by 'Resulttime'"
    connstring = "ODBC;DSN=SQLDSN;UID=test;PWD=test123"

    Rows(1).Insert
    Set thisQT = ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("a1", "a1000"))

    thisQT.BackgroundQuery = False
    thisQT.Sql = sqlstring
    thisQT.Refresh
End Sub