Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i map values in a table to the excel tab via code.

Status
Not open for further replies.

Pack10

Programmer
Feb 3, 2010
495
US
I am in the later stages of my task. I have stripped the crlf's and built a table and have the data in a table the way i want it in access. I want to send it to an excel file with several (7) worksheets depending on the value in the field I have cleansed. So I want to read the table, and map it to the appropriate tab. I can do this if i create a separate query for each of the 7 types with a copyfromRecordset. Not sure of the syntax here.
If my field was named field1...and the tab was "FSB" how could I do this.
 
You just export to the same file multiple times... The below has variables for the path and file but you can see it outputs two different queries to different sheets (tabs), Detail and Summary...

Code:
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qry detail", strPath & strFile, True, "Detail"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qry Summary", strPath & strFile, True, "Summary"
 
I forgot to mentions you can also directly export tables instead of queries.
 
I can do this if i create a separate query for each of the 7 types with a copyfromRecordset
So, where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I ended up doing it in 7 queries each query sending its records to the particular sheet.
But I want to try to do it in 1 sub instead of separate queries and sub routines for each tab.

Since I changed from copyfromrecordset to a while loop, I think i can do this now.
I had some issues with memo fields with the copyfromrecordset.
 
...and your code is???

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top