I am having a problem with a recordset not being created. I am able to create a recordset in step 1 and loop thru all column names. I try doing the same with another table, but I first delete all the records then I created 1 blank record...because I thought this might help, but still not able to loop thru all the column names in this second table in Step 2. In step 1, the table is an xls linked table. In step 2, the table is a sql linked table.


rstD = nothing when I check after running this line below: Set rstD = db.OpenRecordset(strsql, dbOpenDynaset)


' STEP 1 ---------------------------------------------------------------------------------
    strsql = "Select top 1 * From [MyTable1]"
    Set rstF = db.OpenRecordset(strsql, dbOpenDynaset)
    
    'Put the Field names into a string variable
    For NumFields = 0 To rstF.Fields.count - 1
       tmpstr = tmpstr & rstF.Fields(NumFields).Name & "|"
    Next


' STEP 2 ---------------------------------------------------------------------------------
    AmzStr = "Delete MyTable2"
    Call SQL_PassThrough(AmzConn, AmzStr)
    
    AmzStr = "Insert Into MyTable2 ([agreementid]) Values('1')"
    Call SQL_PassThrough(AmzConn, AmzStr)


    strsql = "Select top 1 * From MyTable2"
    Set rstD = db.OpenRecordset(strsql, dbOpenDynaset)


    'Put the Field names into a string variable
    For NumFields2 = 0 To rstD.Fields.count - 1
       tmpstr2 = tmpstr2 & rstD.Fields(NumFields2).Name & "|"
    Next