Thread: Column Name
View Single Post
  #1  
Old May 13th, 2010, 03:09 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default Column Name

Hi

I am using this code to send data into excel

Set rst = CurrentDb.OpenRecordset("SELECT Temp.* FROM Temp;")
rst.MoveFirst
Do While Not rst.EOF
objSht.Cells(iRow, 1).Value = rst!main_id
objSht.Cells(iRow, 2).Value = rst!year_id
iRow = iRow + 1
rst.MoveNext
Loop
rst.Close
End With

But how would I modify my code if I dont know the name of the columns?

objSht.Cells(iRow, 1).Value = rst!column1
objSht.Cells(iRow, 1).Value = rst!column2

objSht.Cells(iRow, 1).Value = rst!(1)
objSht.Cells(iRow, 1).Value = rst!(2)

Thank you all

Bre-x