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 / Importing / Linking / May 2005

Tip: Looking for answers? Try searching our database.

export query results at the push of a button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
virgirl920 - 26 May 2005 16:08 GMT
Hi.  I have been trying to save my query results as an Excel document at the
push of a command button, but it is not working.  I also want the user to be
able to enter the file name to save the results as.

I have tried doing this using a Macro, using VB (both using
TransferSpreadsheet), and using the code below by Dylan Moran, all of which
do not work.

When using the transferSpreadsheet command, I am not sure how to use the
FilePath part, since I had the user enter a new spreadsheet to create.  How
would I do this, if the user enters the name in a textbox?  It keeps sayng it
is an invalid path.  This is the VB code that I have tried to use:

fileName = Me!txtFileName.Text

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel5,
"qryDealerInfo", ["Desktop\" + fileName(*.xls)], True

The brackets are very wrong and result in many errors, but that's what I
want the file saved to be.  That's just the latest way I've tried.

In Dylan Moran's code, the ahtAddFilterItem is getting an error...do I have
to import some files, or have additional code so it recognizes what aht...is?

I would appreciate any solution that lets me do this.  I am completely new
to Access (only learned it this past week).

Dim strFilter As String
Dim strSaveFileName As String

 'Display dialog
 strFilter = ahtAddFilterItem(strFilter, _
     "Excel Files (*.XLS)", "*.XLS")
 strSaveFileName = ahtCommonFileOpenSave( _
     OpenFile:=False, _
     Filter:=strFilter, _
     Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)

 If Len(strSaveFileName) > 0 Then 'User entered a filename
   DoCmd.TransferSpreadsheet acExport, _
       acSpreadsheetTypeExcel8, "EnterQueryNameHere", _
       strSaveFileName
 Else 'User pressed Cancel
   'Do nothing

 End If
virgirl920 - 26 May 2005 17:15 GMT
I've resolved this, sorry.  If I could figure out how to delete posts I would
delete this one!

> Hi.  I have been trying to save my query results as an Excel document at the
> push of a command button, but it is not working.  I also want the user to be
[quoted text clipped - 42 lines]
>
>   End If
 
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.