Extract Specific Data from Access

iamstupid

New member
Local time
Today, 07:03
Joined
May 25, 2011
Messages
7
Hi guys, was wondering from Access , is it possible to just extract specific data only ?

my codes are as followed:

Dim rst As DAO.Recordset
Dim ApXL As Object
Dim xlWBk As Object
Dim xlWSh As Object
Dim fld As DAO.Field
Dim strPath As String
Const xlCenter As Long = -4108
Const xlBottom As Long = -4107


strPath = "C:\Tests.xls"
Dim SeriesNo As String

strTQname = "tblUnderlyingStocks"

('SeriesNo = "820"
'strTQname = "SELECT * FROM tblUnderlyingStocks WHERE Series No = SeriesNo ") <--- but i want something like this

Dim strSheetName As String
strSheetName = "Sheet1"

Set rst = CurrentDb.OpenRecordset(strTQname)
Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Open(strPath)
ApXL.Visible = True
Set xlWSh = xlWBk.Worksheets(strSheetName)

xlWSh.Range("A1").Select
For Each fld In rst.Fields
ApXL.ActiveCell = fld.Name
ApXL.ActiveCell.Offset(0, 1).Select
Next
rst.MoveFirst
xlWSh.Range("A2").CopyFromRecordset rst

Thank for the help in advance !
 
Since SeriesNo is apparently a string variable I assume that the field is too.

Code:
" ... WHERE [Series No] ='" & SeriesNo & "'"
 

Users who are viewing this thread

Back
Top Bottom