Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

exporting codes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lauren B - 31 Mar 2005 17:24 GMT
I have five queries that I would like to export into one Excel document
(have each query be a separate tab).  Is there a way to write code for a
command button that will automatically export these queries to Excel?

Thank you in advance for any assistance.

LB
John Vinson - 31 Mar 2005 18:30 GMT
>I have five queries that I would like to export into one Excel document
>(have each query be a separate tab).  Is there a way to write code for a
[quoted text clipped - 3 lines]
>
>LB

Yes. See the VBA help for the TransferSpreadsheet method. You can
specify Excel ranges in the method's operands.

                 John W. Vinson[MVP]    
Charles - 31 Mar 2005 19:07 GMT
Hi I have always found it is easier to create a csv file
on the desktop use the following -

Add this code to the button or trigger you want.  For it
to work you have to make a query called querynamehere or
rename to whatever you like.

hope that helps

Charles

Dim path As String
Dim wShell As Object
Dim strSql As String

Set wShell = CreateObject("WScript.Shell")
path = wShell.SpecialFolders("Desktop")
path2 = CurrentProject.path

Set wShell = Nothing

DoCmd.TransferText acExportDelim, , "qrynamehere", path
+ "\export" & Format(Now(), "ddmmyyyy") & ".csv", True

MsgBox ("You will now find a file on the desktop if you
left the code as you found it in the above.  If add a 2
to the end of the word "path" the file will be placed in
the databases root directory"), vbInformation, "Msgbox
title here"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.