Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim DropTable As String, CreateTable As String, AppendTable1 As String, AppendTable2 As String
'DropTable = "Drop table LongFields" 'Not needed for first execution
CreateTable = "CREATE TABLE LongFields ([key] [int] IDENTITY (1, 1) NOT NULL ," & _
"[1] [varchar] (7000) NULL , [2] [varchar] (7000) NULL , [3] [varchar] (7000) NULL ," & _
"[4] [varchar] (7000) NULL , [5] [varchar] (7000) NULL , [6] [varchar] (7000) NULL ," & _
"[7] [varchar] (7000) NULL , [8] [varchar] (7000) NULL , [9] [varchar] (7000) NULL ," & _
"[10] [varchar] (7000) NULL , [11] [varchar] (7000) NULL , [12] [varchar] (7000) NULL ," & _
"[13] [varchar] (7000) NULL , [14] [varchar] (7000) NULL , [15] [varchar] (7000) NULL ," & _
"[16] [varchar] (7000) NULL , [17] [varchar] (7000) NULL , [18] [varchar] (7000) NULL ," & _
"[19] [varchar] (7000) NULL , [20] [varchar] (7000) NULL)"
AppendTable1 = "Insert into LongFields values ('abc', 'abc', 'abc', 'abc', 'abc'," & _
"'abc', 'abc', 'abc', 'abc', 'abc'," & _
"'abc', 'abc', 'abc', 'abc', 'abc'," & _
"'abc', 'abc', 'abc', 'abc', 'abc')"
AppendTable2 = "Insert into LongFields values ('xyz', 'xyz', 'xyz', 'xyz', 'xyz'," & _
"'xyz', 'xyz', 'xyz', 'xyz', 'xyz'," & _
"'xyz', 'xyz', 'xyz', 'xyz', 'xyz'," & _
"'xyz', 'xyz', 'xyz', 'xyz', 'xyz')"
conn.CursorLocation = adUseServer
conn.Open "DSN=Pubs;User Id=<username>;Password=<strong password>;Database=Pubs;"
'conn.Execute DropTable 'Not needed for first execution
conn.Execute CreateTable
conn.Execute AppendTable1
conn.Execute AppendTable2
rs.ActiveConnection = conn
rs.Properties("Hold Rows") = True
rs.CursorType = adOpenKeyset
rs.Open "select * from LongFields"
rs.MoveNext '<--- Code fails here
rs.Close
conn.Close
End Sub