Computer Learning Zone CLZ Access Excel Word Windows

The cosmic perspective reminds us that in space, where there is no air, a flag will not wave - an indication that perhaps flag waving and space exploration do not mix.

-Neil deGrasse Tyson
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access SQL Seminar Part 2    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Table SQL
Richard L 
    
10 years ago
Yes,  I made an input form not unlike the ones from the "Search Seminars" usind VB Code(Lesson 23).  If I had a query I could just use.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "QUERYNAME", _
        "C:\Users\Rix Computer\Desktop\TRUSTED\Tonys Project\Results.xlsx"
    
BUT I don't have a query I have a vb code that takes an SQL string and places it in a listbox:

ResultsList.RowSource = SQL

I made a query that on the ID I putas a criterion. Forms!InputF!ListBox...
problem it only takes the record highlighted in the listbox, not all the records in the listbox once I requery it to do a search.

This wouild be clearer if I could email you an attachment and you can see what I'm getting at...

I want an input form where I enter specific WHERE conditions hit search and generate a result in the listbox and then have ALL the results export to a spreadsheet... I have made a request to even pay for this help.


Reply from Alex Hedley:

Unfortunately TechHelp isn't available at the minute, I'm sure there's a message on the page.

I'm hoping for Rich to release a written tutorial I've done on Exporting Objects from Access which covers this in much detail but for now I'll show you a quick example:


Dim db As DAO.Database
Dim qdf As QueryDef

Dim strTempTable As String: strTempTable = "tblTempExport"
Dim strTempQuery As String: strTempQuery = "qryTempExport"
    
strSQL = "SELECT ..."
    
On Error Resume Next
DoCmd.DeleteObject acTable, strTempTable
On Error Resume Next
DoCmd.DeleteObject acQuery, strTempQuery

strSQL = strSQL & "... INTO " & strTempTable & " FROM ...;"

Set db = CurrentDb()
Set qdf = db.CreateQueryDef(strTempQuery)
qdf.SQL = strSQL
qdf.Execute

qdf.Close


Now I'm putting data from a Query into a Table so I use the Table elsewhere, you could just use the query you've created.

Now you can use this Query in your export command.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access SQL Seminar Part 2.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/17/2026 10:28:32 PM. PLT: 1s