A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

OutputTo Excel File Name



 
 
Thread Tools Display Modes
  #1  
Old April 30th, 2008, 08:19 AM posted to microsoft.public.access.forms
Eric[_7_]
external usenet poster
 
Posts: 13
Default OutputTo Excel File Name

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
  #2  
Old April 30th, 2008, 08:46 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default OutputTo Excel File Name

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


"Eric" wrote in message
...
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



  #3  
Old April 30th, 2008, 06:21 PM posted to microsoft.public.access.forms
Eric[_7_]
external usenet poster
 
Posts: 13
Default OutputTo Excel File Name

On Apr 30, 12:46 am, "Jeanette Cunningham"
wrote:
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

"Eric" wrote in message

...

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


That worked perfectly. Thank you very much!!
 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.