Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2008, 12:08 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default SELECT * FROM... from code

Hi,

I'm trying to do a SELECT * and have the results return to me as though I would have done it via the query method through vba code... but not sure how to do it...

Tried doCmd.runSql doesn't work... and I have not other ideas...

thank you

 
Old February 26th, 2008, 08:42 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Normally you open a connection and recordset using DAO or ADO. I use ADO exclusively since I do a lot of Access/SQL. The real issue is, what do you want to do with the data? That will determine the best method to use.

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old February 26th, 2008, 09:38 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey,

I would want the data to appear just the same way as if I would have done the query through the query method in Access... I just want the data to show up on the screen... all of it...

 
Old February 26th, 2008, 12:58 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Disregard... figured it out by taking a round about way of doing it...

    Dim objExcel As Object
    Dim sqlStr As String
    Dim objWBs As Object, objXLWB As Object

    sqlStr = "SELECT * INTO TempReport FROM Table_Name WHERE cell = val"

    'Insert data into a temporary table, then output the file to an xl file.
    DoCmd.RunSQL (sqlStr)
    DoCmd.OutputTo acOutputTable, "TempReport", acFormatXLS, "output.xls"
    DoCmd.RunSQL ("DROP TABLE TempReport")

    'Open said excel file...
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    Set objWBs = objExcel.Application.Workbooks
    objWBs.Open FileName:="output.xls", UpdateLinks:=1






Similar Threads
Thread Thread Starter Forum Replies Last Post
code on page 218 two select statements in one uvis130 BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 0 September 3rd, 2007 06:56 AM
Combobox Select/Insert Code osemollie Pro VB Databases 4 June 28th, 2006 09:09 AM
Here's One for the Pro's - Select All CODE JpaulH Access VBA 7 June 5th, 2006 04:05 PM
Select From Where Code not working...help bidatad Access VBA 2 April 1st, 2005 03:25 PM
Select Query Code stevewardau Access 4 July 9th, 2003 01:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.