pmjg23
asked on
Run-time error '3125'
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\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_AB S", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_ Eqty", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_Eq ty", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_ LTDbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_LT Dbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_ STDbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_ST Dbt", "J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. xls", True, ""
Call Shell("""C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" " ""J:\REG REP\JPMREPORT\Treasury Surveys\Database\Excel\rpt Country_Se curities1. 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.
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_AB
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_Eq
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_LT
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_PriorYear_ST
Call Shell("""C:\Program Files\Microsoft Office\Office10\EXCEL.EXE"
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.
ASKER
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
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
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?
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?
ASKER
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?
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?
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_
to
DoCmd.TransferSpreadsheet acExport, 8, "qryRpt_Cntry_CurrentYear_