Here's a tip...
Some of the databases out there are not code monkey friendly and I for one hate typing all those field names over and over.
Use VBA to write the code for you...
Open SQL or Access and EXPORT to excel, select just one line, make sure you tell it only selected data. Pasted to the top of the worksheet, You should get the all the table headers in a straight horizontal line across the worksheet.
Put a button on the sheet, and in code mode, enter this:
<code>
Private Sub CommandButton1_Click()
For c = 1 To 20
Sheet1.Cells(c + 5, 2) = "Rst(""" & Sheet1.Cells(1, c) & """)=NewSheet(""Sheet1"").cells(NewRow," & LTrim(Str(c)) & ")"
Next c
End Sub
</code>
Your now vertical output on the sheet looks like this, and IS valid code:
<code>
Rst("ID")=NewSheet("Sheet1").cells(NewRow,1)
Rst("TraceID")=NewSheet("Sheet1").cells(NewRow,2)
Rst("FileType")=NewSheet("Sheet1").cells(NewRow,3)
Rst("FileDate")=NewSheet("Sheet1").cells(NewRow,4)
Rst("Action")=NewSheet("Sheet1").cells(NewRow,5)
Rst("Account_Name")=NewSheet("Sheet1").cells(NewRow,6)
Rst("Item_Norway_Type")=NewSheet("Sheet1").cells(NewRow,7)
Rst("Item_Tuskeegee_Type")=NewSheet("Sheet1").cells(NewRow,8)
Rst("MID")=NewSheet("Sheet1").cells(NewRow,9)
Rst("Item_Rondell_Type")=NewSheet("Sheet1").cells(NewRow,10)
Rst("E4_ID")=NewSheet("Sheet1").cells(NewRow,11)
Rst("Item_Description")=NewSheet("Sheet1").cells(NewRow,12)
Rst("Details")=NewSheet("Sheet1").cells(NewRow,13)
Rst("")=NewSheet("Sheet1").cells(NewRow,14)
Rst("")=NewSheet("Sheet1").cells(NewRow,15)
Rst("")=NewSheet("Sheet1").cells(NewRow,16)
Rst("")=NewSheet("Sheet1").cells(NewRow,17)
Rst("")=NewSheet("Sheet1").cells(NewRow,18)
Rst("")=NewSheet("Sheet1").cells(NewRow,19)
Rst("")=NewSheet("Sheet1").cells(NewRow,20)
</code>
Just copy and paste the lines you need after that pesky connection statement, and they're even spelled right!
cheers
lolly
Some of the databases out there are not code monkey friendly and I for one hate typing all those field names over and over.
Use VBA to write the code for you...
Open SQL or Access and EXPORT to excel, select just one line, make sure you tell it only selected data. Pasted to the top of the worksheet, You should get the all the table headers in a straight horizontal line across the worksheet.
Put a button on the sheet, and in code mode, enter this:
<code>
Private Sub CommandButton1_Click()
For c = 1 To 20
Sheet1.Cells(c + 5, 2) = "Rst(""" & Sheet1.Cells(1, c) & """)=NewSheet(""Sheet1"").cells(NewRow," & LTrim(Str(c)) & ")"
Next c
End Sub
</code>
Your now vertical output on the sheet looks like this, and IS valid code:
<code>
Rst("ID")=NewSheet("Sheet1").cells(NewRow,1)
Rst("TraceID")=NewSheet("Sheet1").cells(NewRow,2)
Rst("FileType")=NewSheet("Sheet1").cells(NewRow,3)
Rst("FileDate")=NewSheet("Sheet1").cells(NewRow,4)
Rst("Action")=NewSheet("Sheet1").cells(NewRow,5)
Rst("Account_Name")=NewSheet("Sheet1").cells(NewRow,6)
Rst("Item_Norway_Type")=NewSheet("Sheet1").cells(NewRow,7)
Rst("Item_Tuskeegee_Type")=NewSheet("Sheet1").cells(NewRow,8)
Rst("MID")=NewSheet("Sheet1").cells(NewRow,9)
Rst("Item_Rondell_Type")=NewSheet("Sheet1").cells(NewRow,10)
Rst("E4_ID")=NewSheet("Sheet1").cells(NewRow,11)
Rst("Item_Description")=NewSheet("Sheet1").cells(NewRow,12)
Rst("Details")=NewSheet("Sheet1").cells(NewRow,13)
Rst("")=NewSheet("Sheet1").cells(NewRow,14)
Rst("")=NewSheet("Sheet1").cells(NewRow,15)
Rst("")=NewSheet("Sheet1").cells(NewRow,16)
Rst("")=NewSheet("Sheet1").cells(NewRow,17)
Rst("")=NewSheet("Sheet1").cells(NewRow,18)
Rst("")=NewSheet("Sheet1").cells(NewRow,19)
Rst("")=NewSheet("Sheet1").cells(NewRow,20)
</code>
Just copy and paste the lines you need after that pesky connection statement, and they're even spelled right!
cheers
lolly