rogerdjr
asked on
Getting an Odd error Run-time 2006 when exporting a CSV file - seems to be substituting the "#" sign for the "." in the export file name
I am getting this odd error - Experts-Exchange-Question-2019-10-2.docxseems to be substituting the "#" sign for the "." in the export file name
SpreadSheetName = Forms![0_masterdatafrm]![D efaultCont rId] & " " & Forms![0_masterdatafrm]![D efaultCont rIdTxt] & " Wkly Cnstr Mtg Notes " & Format(Me![MeetingNumber], "000") & " " & Format(Me![MeetingDate], "mm-dd-yyyy") & " " & TableToExport & ".csv"
MsgBox SpreadSheetName & vbNewLine & vbNewLine & "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\" & SpreadSheetName
Results –
DoCmd.TransferText acExportDelim, , TableToExport, "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\" & SpreadSheetName, False
Results –
SpreadSheetName = Forms![0_masterdatafrm]![D
MsgBox SpreadSheetName & vbNewLine & vbNewLine & "J:\Projects\_CM-OwnerRep\
Results –
DoCmd.TransferText acExportDelim, , TableToExport, "J:\Projects\_CM-OwnerRep\
Results –
How about using a much simpler name for export filename e.g. C:\Temp\myExport.csv to actually test the export functionality...if that works ,work your way substituting one thing at a time.
ASKER
Did that - "Test.csv" works fine
Other spreadsheets with similar naming string work fine - appears to be the delimited file that is acting up
Went to delimited file because the table has 19,000 items and it was giving an error that it was to many items for a spreadsheet
Other spreadsheets with similar naming string work fine - appears to be the delimited file that is acting up
Went to delimited file because the table has 19,000 items and it was giving an error that it was to many items for a spreadsheet
At first probably it would be a good idea to avoid too much formatting on the name....just follow a rule like myExcel10272019 and you should be fine.
Interesting that on a lot of lines the transferSpreadsheet bombs out......i don't use it so i don't know it had that limitation...on the other hand using automation you can easily bypass this as you will append data on chunks....i think i had recently around 50,000 lines for a client of mine exported in chunks of 1000s...its a bit slower that the builtin mechanism but if Excel can handle the load so does this
Interesting that on a lot of lines the transferSpreadsheet bombs out......i don't use it so i don't know it had that limitation...on the other hand using automation you can easily bypass this as you will append data on chunks....i think i had recently around 50,000 lines for a client of mine exported in chunks of 1000s...its a bit slower that the builtin mechanism but if Excel can handle the load so does this
How about replacing the '.' after 198008 with something else?
In fact it might be an idea to replace any '.' in the filename with something else.
In fact it might be an idea to replace any '.' in the filename with something else.
SpreadSheetName = Replace(Forms![0_masterdatafrm]![DefaultContrId] & " " & Forms![0_masterdatafrm]![DefaultContrIdTxt] & " Wkly Cnstr Mtg Notes " & Format(Me![MeetingNumber], "000") & " " & Format(Me![MeetingDate], "mm-dd-yyyy") & " " & TableToExport, ".", "-") & ".csv"
ASKER
FYI
These code lines work fine for a smaller table
TableToExport = "81_ConstrMtgNotesWkgTable OfFiguresT bl"
SpreadSheetName = Rstx![ContractId] & " " & Rstx![ContractDescrp] & " Wkly Cnstr Mtg Notes " & Format(Me![MeetingNumber], "000") & " " & Format(Me![MeetingDate], "mm-dd-yyyy") & " " & TableToExport & ".xls"
DoCmd.OutputTo acOutputTable, TableToExport, "MicrosoftExcel(*.xls)", "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\" & SpreadSheetName, False
These code lines work fine for a smaller table
TableToExport = "81_ConstrMtgNotesWkgTable
SpreadSheetName = Rstx![ContractId] & " " & Rstx![ContractDescrp] & " Wkly Cnstr Mtg Notes " & Format(Me![MeetingNumber],
DoCmd.OutputTo acOutputTable, TableToExport, "MicrosoftExcel(*.xls)", "J:\Projects\_CM-OwnerRep\
You're not showing the resulting file names. The last '.' in a Windows file name is the extension separator. Sometimes applications limit the acceptable extensions that you can use.
https://en.wikipedia.org/wiki/Filename
https://en.wikipedia.org/wiki/Filename
ASKER
The example that successfully executes is
19008.001-001 Crocker Roof Wkly Cnstr Mtg Notes 007 10-23-2019 81_ConstrMtgNotesWkgTableO fFiguresTb l.xls
The one that fails is
19008.001-001 Crocker Roof Wkly Cnstr Mtg Notes 007 10-23-2019 81_ConstrMtgNotesWkgTbl.cs v
19008.001-001 Crocker Roof Wkly Cnstr Mtg Notes 007 10-23-2019 81_ConstrMtgNotesWkgTableO
The one that fails is
19008.001-001 Crocker Roof Wkly Cnstr Mtg Notes 007 10-23-2019 81_ConstrMtgNotesWkgTbl.cs
Was "Test.csv" exporting the same data?
ASKER
yes
what seems to be happening is this command seems seems to be plugging in the # symbol for the . symbol
what seems to be happening is this command seems seems to be plugging in the # symbol for the . symbol
Do you have a screenshot or something that shows that?
ASKER
See the attachment with the posting
Experts-Exchange-Question-2019-10-2.docx
Experts-Exchange-Question-2019-10-2.docx
Interesting. Try a shorter file name with '.' in it. Note that it says it's a Microsoft Access problem, not a Windows problem. This is the only page I found that talks about error 2006 and it appears to be a generic error.
https://www.solvusoft.com/en/errors/runtime-errors/microsoft-corporation/microsoft-access/2006-the-object-name-you-entered-doesn-t-follow-microsoft-office-access-object-naming-rules/
https://www.solvusoft.com/en/errors/runtime-errors/microsoft-corporation/microsoft-access/2006-the-object-name-you-entered-doesn-t-follow-microsoft-office-access-object-naming-rules/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
rogerdjr
Have you tried my suggestion of replacing any '.' in the name with another character?
Have you tried my suggestion of replacing any '.' in the name with another character?
ASKER
Used this code to solve the problem - works great
SpreadSheetName = Forms![0_masterdatafrm]![D efaultCont rId] & " " & Forms![0_masterdatafrm]![D efaultCont rIdTxt] & " Wkly Cnstr Mtg Notes " & Format(Me![MeetingNumber], "000") & " " & Format(Me![MeetingDate], "mm-dd-yyyy") & " " & TableToExport & ".csv"
DoCmd.TransferText acExportDelim, , TableToExport, "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\temp.csv", False
VBA.FileCopy "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\temp.csv", "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\" & SpreadSheetName
VBA.Kill "J:\Projects\_CM-OwnerRep\ ProjMngmtD ataBase\Re f Proj Spreadsheets - Current\temp.csv"
Thanks to all
SpreadSheetName = Forms![0_masterdatafrm]![D
DoCmd.TransferText acExportDelim, , TableToExport, "J:\Projects\_CM-OwnerRep\
VBA.FileCopy "J:\Projects\_CM-OwnerRep\
VBA.Kill "J:\Projects\_CM-OwnerRep\
Thanks to all
You are welcome!
Why FileCopy/Kill?
You could use Name.
You could use Name.
Dim strPath As String
Dim strTempName As String
strPath = "J:\Projects\_CM-OwnerRep\ProjMngmtDataBase\Ref Proj Spreadsheets - Current\"
strTempName = "temp.csv"
DoCmd.TransferText acExportDelim, , TableToExport, strPath & strTempName, False
Name strPath & strTempName As strPath & SpreadSheetName
@rogerdjr: Thanks! Glad I was able to help….