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 / April 2008

Tip: Looking for answers? Try searching our database.

OutputTo Excel File Name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 30 Apr 2008 08:19 GMT
I have a button on form that exports out a select query to an Excel
spreadsheet using the OutputTo function.  The button works great.  It
does everything I want it to (thanks to the this group).  However,
there is one thing that I cannot get it to do, and that is get the
correct file name.  I am managing several projects and I am keeping a
database of QC tracking for various projects.  I built a form called
Project Selector that allows me to select a specific project from an
unbound combo box which creates a filter to show me only the data from
that Project.  The combo box is populated by the project names pulled
from a table with the project names and an ID field, using the
following code:

SELECT domProject.ProjectID, domProject.ProjectName FROM domProject
ORDER BY domProject.ProjectName; .

The query, report, and the other forms are linked back to the project
ID.  My OutputTo code is as follows:

Dim stDocName As String

   stDocName = "C:\PFData\" & Me.ProjectName.Value & "QC" & ".xls"
   DoCmd.OutputTo acOutputQuery, "qryProjectQC", acFormatXLS,
stDocName, False

The filename that it creates is 1QC.xls or 5QC.xls.  1 and 5 being the
Project ID.  How can I get to name the file using the project name
instead of the project ID?

Thanks,
Eric
Jeanette Cunningham - 30 Apr 2008 08:46 GMT
Eric,
Me.ProjectName.Value gives you the ProjectID from the combo? is this
correct?
Assuming ProjectName is the name of the combo on the form?
If Yes, then use Me.ProjectName.Column(1) instead of Me.ProjectName.Value.
Note: you don't need to use .Value at all.

Jeanette Cunningham -- Melbourne Victoria Australia

>I have a button on form that exports out a select query to an Excel
> spreadsheet using the OutputTo function.  The button works great.  It
[quoted text clipped - 26 lines]
> Thanks,
> Eric
Eric - 30 Apr 2008 18:21 GMT
On Apr 30, 12:46 am, "Jeanette Cunningham"
<n...@discussions.microsoft.com> wrote:
> Eric,
> Me.ProjectName.Value gives you the ProjectID from the combo? is this
[quoted text clipped - 35 lines]
> > Thanks,
> > Eric

That worked perfectly.  Thank you very much!!
 
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.