Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lookup data in a variable table & retrieve data from a pivot table | Excel Worksheet Functions | |||
How to get access 2003 data table particular data in excel. | Excel Programming | |||
Write data to Access table with INSERT when table has auto number | Excel Programming | |||
Importing data from Access to Excel, but I need to vary the table from Access | Excel Programming | |||
Lookup Access data in Excel | Excel Worksheet Functions |