?
Solved

Run-time error '3125'

Posted on 2007-08-06
7
Medium Priority
?
2,089 Views
Last Modified: 2013-11-28
I am using the following code to export data from an MS Access db to Excel:

DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_ABS", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_ABS", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_Eqty", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_Eqty", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_LTDbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_LTDbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_STDbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_STDbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
    Call Shell("""C:\Program Files\Microsoft Office\Office10\EXCEL.EXE"" ""J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", 1)

When I run the code I receive the following error "Run-time error '3125'. It is odd to me since I am using the same exact code in various other MS Access db's that I have created without any issues. I have the db set to compact and repair upon closing, and have created a new mdb file and imported all objects and still receive the same error. Any assistance or thoughts would be very helpful. I am finishing up this project on my current assignment and need to finish by this Friday.
0
Comment
Question by:pmjg23
6 Comments
 
LVL 19

Expert Comment

by:frankytee
ID: 19643058
have you set a breakpoint to see where the code fails? which line does it occur?

check that all the queries exists and try removing the last argument as it relates to an xl range which is usually used for import not export.
ie
change
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_ABS", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True, ""
to
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_ABS", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rptCountry_Securities1.xls", True
0
 

Author Comment

by:pmjg23
ID: 19643089
Hi frankytee,

It occurs for all lines of code, and have already checked naming conventions for queries. Will try what you suggested for fix and will let you know results. Thanks
0
 
LVL 14

Expert Comment

by:wsh2
ID: 19643803
J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\

Is the J: drive mapped to this computer?

Do you have write permissions to "REG REP\JPMREPORT\Treasury Surveys\Database\Excel\" ?

Is the read-only attribute on for the spreadsheet file?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:pmjg23
ID: 19645389
Hi frankytee,
What you suggested did not work. Do you have any other suggestions relating specifically to the error? "Run-time error '3125': "is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long."

I have tested by changing the name of the queries to "qrytest" and I still receive the error?
0
 

Author Comment

by:pmjg23
ID: 19647809
I found the solution, I needed to minimize some of the field names in the main table, since when exporting data into excel if within the query the joins go over a certain total it will produce that error.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19984852
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question