X
XP
Using Office 2003 and Windows XP;
I have set up this sort of thing before without issue and now I'm clueless
(I must be losing it) as to why the following function in a standard code
module generates an error (item cannot be found in the collection
corresponding to the requested name or ordinal). Can someone please remind me
what I'm missing - [and thanks much in advance] ?
Private Function TestRecordset()
Dim sSQL As String
Dim rs As ADODB.Recordset
Dim sResult As String
Dim iCols As Integer
Dim iX As Integer
sSQL = "SELECT Table1.* FROM Table1;"
Set rs = CurrentProject.Connection.Execute(sSQL)
iCols = rs.Fields.Count - 1
rs.MoveFirst
Do
For iX = 0 To iCols + 1
sResult = sResult & ";" & rs!Fields(iX).Value & vbCr
Next iX
rs.MoveNext
Loop Until rs.EOF
MsgBox sResult
End Function
Also, please note that the SQL works fine in a query...
I have set up this sort of thing before without issue and now I'm clueless
(I must be losing it) as to why the following function in a standard code
module generates an error (item cannot be found in the collection
corresponding to the requested name or ordinal). Can someone please remind me
what I'm missing - [and thanks much in advance] ?
Private Function TestRecordset()
Dim sSQL As String
Dim rs As ADODB.Recordset
Dim sResult As String
Dim iCols As Integer
Dim iX As Integer
sSQL = "SELECT Table1.* FROM Table1;"
Set rs = CurrentProject.Connection.Execute(sSQL)
iCols = rs.Fields.Count - 1
rs.MoveFirst
Do
For iX = 0 To iCols + 1
sResult = sResult & ";" & rs!Fields(iX).Value & vbCr
Next iX
rs.MoveNext
Loop Until rs.EOF
MsgBox sResult
End Function
Also, please note that the SQL works fine in a query...