LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default How to get lookup data from Access Table

The record set (RS) defines the cells to return. So this is the section that
needs to be modified. I included comment in the rows below


A record set is a filter set of rows and columns from a table. Can come
from access but can also be used to return rows and columns from an excel
spreadsheet. Microsoft treats access tables and excel worksheets the same.

With RS
' open the recordset


Select the table from access or a worksheet frim excel

.Open TableName, cn, adOpenStatic, adLockOptimistic,adCmdTable
' all records

The * in the Select indicates you are returning all columns in the table. m
the SELCT is the start of the SQL (String Query Language)


This line is commented out. the comments need to be remove. and the vbcrlf
need to be added. Repelace MyCriteria with any filtered text you like.

MySQL = "SELECT * FROM " & TableName & vbCRLF & _
"WHERE [TableName.FieldName] = " chr(34) & MyCriteria" & chr(34)

.Open MySQL, cn, , , adCmdText ' filter records


RS2WS RS, TargetRange ' write data from the recordset to the
'worksheet
' ' optional approach for Excel 2000 or later (RS2WS is not
'necessary)
For intColIndex = 0 To rs.Fields.Count - 1 ' the field names
TargetRange.Offset(0, intColIndex).Value = rs.Fields
(intColIndex).Name
Next
' the recordset data
TargetRange.Offset(1, 0).CopyFromRecordset rs

End With


 
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
Lookup data in a variable table & retrieve data from a pivot table Shawna Excel Worksheet Functions 3 October 10th 08 11:11 PM
How to get access 2003 data table particular data in excel. Anupam Soral Excel Programming 1 July 18th 08 02:58 PM
Write data to Access table with INSERT when table has auto number Hokievandal Excel Programming 1 December 20th 06 01:19 AM
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
Lookup Access data in Excel Chris Kellock Excel Worksheet Functions 1 December 28th 04 01:51 PM


All times are GMT +1. The time now is 08:22 AM.

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"