Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're the man! Thanks!
-----Original Message----- Ed The following code should get you started. It is slightly different from your request in that it creates a temporary query rather than updates an existing MS Access query. Generation of the sql from the variables in your spreadsheet should be reasonably easy. The output only has one heading as the table has one field. This will have to be modified. When you build the code, you will have to reference the DAO 2.5/3.5 compatibility library. To do this in the VBE, go Tools, References, scroll down to the library and check. Tony Sub ccc() Dim wrkjet As workspace Dim dbs As database Dim qdef As QueryDef Dim rst As Object Dim wks As Worksheet, cl As Integer, rw As Integer Dim mydatabase As String Dim myquery As String mydatabase = "full\path\and\databasename.mdb" Set wrkjet = CreateWorkspace("", "admin", "", dbUseJet) Set dbs = wrkjet.OpenDatabase(mydatabase) myquery = "select * from tablename where field like 'b*'" Set qdef = dbs.CreateQueryDef("", myquery) With qdef Set rst = .OpenRecordset() End With Set ws = Worksheets("sheet2") With ws .Range("a1").Value = rst.Fields(0).Name .Range("a2").CopyFromRecordset rst End With rst.Close dbs.Close wrkjet.Close Set ws = Nothing Set wrkjet = Nothing Set rst = Nothing Set dbs = Nothing Set qdef = Nothing End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Access Queries not seen in Excel | Excel Discussion (Misc queries) | |||
Access Queries into Excel | Excel Worksheet Functions | |||
Queries from Excel 2003 to Access | Excel Discussion (Misc queries) | |||
Excel Queries using Access data | Excel Discussion (Misc queries) | |||
Using Excel Worksheets like Access Queries | Links and Linking in Excel |