AlexTardif
Programmer
Hi,
I got an Excel 2003 worksheet that I want to fill with data from Oracle. My query is on 5 fields, I want to display 4 of them but, the fifth one is only for some work and calculations that updates the recordset. I don't want the fifth field to be displayed.
So, I want to hide, remove or delete the field from my recordset. If I try rst.Fields.delete(3), I get no error but, my field is still there. I've read on some forums to use the update method after the deletion. If I add rst.Fields.Update, I get a runtime error saying this object cannot execute this action.
Dim strSQL as String
dim rst as ADOBD.Recordset
strSQL = "SELECT FIELD1, FIELD2, FIELD3, FIELD4, FIELD5" & VBCRLF & _
"FROM MY_TABLE " & VBCRLF & _
"WHERE FIELD2 = 'MY_VALUE'"
'My connection "conn" comes from another procedure and it works because I get the data I want
rst.open strSQL conn adOpenForwardOnly
Set rst = CalcAndWorks(rst)
'I wanna get rid of the FIELD4
rst.close 'the recordset gotta be closed to execute the Delete
rst.Fields.Delete(3)
'rst.Fields.Update
'Reopen to copy into Excel
rst.open
ActiveCell.CopyFromRecordset rst
rst.close
set rst = nothing
Any help would be welcome!
Thanks!
Alex
I got an Excel 2003 worksheet that I want to fill with data from Oracle. My query is on 5 fields, I want to display 4 of them but, the fifth one is only for some work and calculations that updates the recordset. I don't want the fifth field to be displayed.
So, I want to hide, remove or delete the field from my recordset. If I try rst.Fields.delete(3), I get no error but, my field is still there. I've read on some forums to use the update method after the deletion. If I add rst.Fields.Update, I get a runtime error saying this object cannot execute this action.
Dim strSQL as String
dim rst as ADOBD.Recordset
strSQL = "SELECT FIELD1, FIELD2, FIELD3, FIELD4, FIELD5" & VBCRLF & _
"FROM MY_TABLE " & VBCRLF & _
"WHERE FIELD2 = 'MY_VALUE'"
'My connection "conn" comes from another procedure and it works because I get the data I want
rst.open strSQL conn adOpenForwardOnly
Set rst = CalcAndWorks(rst)
'I wanna get rid of the FIELD4
rst.close 'the recordset gotta be closed to execute the Delete
rst.Fields.Delete(3)
'rst.Fields.Update
'Reopen to copy into Excel
rst.open
ActiveCell.CopyFromRecordset rst
rst.close
set rst = nothing
Any help would be welcome!
Thanks!
Alex