Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Help! Excel multiple worksheet populate from recordset

Using Access2000, the sample code below is what I have been modifying and
working on since the past week and I could not get it to work properly.

What I wanted to accomplish:
1) read from a recordset and export to Excel
2) Excel is populated based from an ID (may possible be one or multiple) and
renames the worksheet based from the ID
3) the code also format the fields

The sample database may be downloaded at:
http://www.geocities.com/mgtulips/sample_db.mdb

TIA!
Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Help! Excel multiple worksheet populate from recordset

Put following in a module in your database..


Sub CreateXLS()
Dim oRS As ADODB.Recordset
Dim oCN As ADODB.Connection
Const sXL = "d:\myexport.xls"

If Dir(sXL) < "" Then Kill sXL

Set oCN = New Connection
oCN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
CurrentDb.Name

Set oRS = oCN.Execute("SELECT DISTINCT t.ID from tmp_result_all as T")
While Not oRS.EOF
oCN.Execute " SELECT * INTO " & _
" [Excel 8.0;Database=" & sXL & "].[" & oRS(0) & "]" & _
" FROM tmp_result_all AS t" & _
" WHERE t.ID = '" & oRS(0) & "';"
oRS.MoveNext
Wend
oRS.Close
oCN.Close


End Sub



ammend & improve where needed... :)



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"B" wrote :

Using Access2000, the sample code below is what I have been modifying
and working on since the past week and I could not get it to work
properly.

What I wanted to accomplish:
1) read from a recordset and export to Excel
2) Excel is populated based from an ID (may possible be one or
multiple) and renames the worksheet based from the ID
3) the code also format the fields

The sample database may be downloaded at:
http://www.geocities.com/mgtulips/sample_db.mdb

TIA!
Bob




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate central worksheet template from multiple worksheets wcurtis Excel Discussion (Misc queries) 0 December 24th 08 10:10 PM
Lookup list from different worksheet & auto-populate multiple cell tomhelle Excel Discussion (Misc queries) 0 November 5th 08 05:37 PM
can excel populate fields in one worksheet to another? AngelaD Excel Worksheet Functions 6 December 22nd 06 12:10 AM
getting multiple data to populate another worksheet nick parker Excel Worksheet Functions 0 January 11th 05 02:59 PM
How to populate a multi-column activeX listbox on a spreadsheet with an ADO recordset quartz Excel Programming 1 May 3rd 04 10:13 PM


All times are GMT +1. The time now is 02:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"