Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 25th, 2008, 12:08 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
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

Reply With Quote
  #2 (permalink)  
Old February 26th, 2008, 08:42 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old February 26th, 2008, 09:38 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
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...

Reply With Quote
  #4 (permalink)  
Old February 26th, 2008, 12:58 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:30 AM.


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