LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
FGM FGM is offline
external usenet poster
 
Posts: 35
Default Data from Access to Excel

windows 2000 xcel/access 2003
I have the following code and am trying to export data from Access to Excel.
However, I want to be able to create worksheets for each set of data and am
sending several groups of data. Need to create x number of worksheets and
name them. Right now my problem is that I have figured out how to send x
number of records with one field but when I use all the fields in the SQL it
does not work.
help would be appreciated.... thanks.

Public Sub TransferSim()
Dim objXLApp As Excel.Application
Dim objXLBook As Excel.Workbook
Dim objQuerySheet As Excel.Worksheet
Dim objResultsSheet As Excel.Worksheet
Dim objXLRange As Excel.Range
Dim db As DAO.Database
Dim strSQL As String
Dim rst1 As Recordset
Dim varResults As Variant
Dim intCount As Integer

Set objXLBook = Workbooks.Add("P:\Templates\Braslau XLT\Simulation.xlt")
Set objXLApp = objXLBook.Parent

objXLBook.Worksheets.Add
objXLBook.ActiveSheet.Name = "test"

objXLApp.Visible = True
objXLBook.Windows(1).Visible = True
' objXLBook.Sheets.Add


' objXLBook.ActiveSheet.Name = "test"


Set db = CurrentDb
' strSQL = "SELECT
ProjectID,SourceNumber,SourceName,ReceiverNumber,R ecordNumber,LapDur,DurSec
FROM tblSourceAnswers Where ProjectID = 22 ORDER BY ReceiverNumber"
strSQL = "SELECT ProjectID,ReceiverNumber,SL,SL_DurSec,SPL FROM
qrySimulationC Where ProjectID = 22 ORDER BY ReceiverNumber"


Set rst1 = db.OpenRecordset(strSQL, dbOpenDynaset)
intCount = rst1.RecordCount
'Set qdfLost = dbThis.QueryDefs("qryLostCount")

varResults = rst1.GetRows(intCount)
rst1.Close
db.Close

Set objXLRange = objXLBook.ActiveSheet. _
Range("A2:E" & 1 + intCount)

objXLRange.FormulaArray = Array(varResults)
Exit Sub


 
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
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
Importing data from Access to Excel, but I need to vary the table from Access Liz L. Excel Programming 3 June 6th 06 02:12 AM
Data too large for Excel, need to query Access data for results Susan[_4_] Excel Programming 8 March 9th 06 03:02 PM
Transfer Data from Excel 2000 to the Access data base André Lavoie Excel Programming 1 September 28th 05 03:22 PM
Access data -work in Excel- save in Access s_u_resh Excel Programming 1 October 25th 04 12:52 PM


All times are GMT +1. The time now is 09:43 PM.

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

About Us

"It's about Microsoft Excel"