473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Export to a CSV file

46
Hi All
Can any one please help me in problem.I want to export details of a access table to a csv file
for that i have written the following code

filepath = "\\accs03-003fs\Databases\Development\ACCFIN_Group_Sales\v2. 0 Development\filename"

DoCmd.TransferText acExportDelim, , "tab_Customers", filepath

but after executing the above command i am getting "Cannot update database or Object is read only".Why is it so..
then one more doubt is that can i export a result of a query to csv file rather than table name.Thanks in advance
Feb 21 '08 #1
5 5720
MindBender77
234 100+
Hi All
Can any one please help me in problem.I want to export details of a access table to a csv file
for that i have written the following code

filepath = "\\accs03-003fs\Databases\Development\ACCFIN_Group_Sales\v2. 0 Development\filename"

DoCmd.TransferText acExportDelim, , "tab_Customers", filepath

but after executing the above command i am getting "Cannot update database or Object is read only".Why is it so..
I believe the problem is deriving from your filepath. I would suggest designing a macro that transfers text first. I find it easier to troubleshoot problems using macros, then migrate your finds to code.

Hope this points you in the right direction,
Bender
Feb 21 '08 #2
cori25
83
Expand|Select|Wrap|Line Numbers
  1. Function test()
  2. Dim db As dao.Database
  3. Set db = CurrentDb
  4.  
  5. Dim strTemp As String
  6.  
  7. strTemp = "C:\Database\test.csv"
  8.  
  9.  
  10. DoCmd.OutputTo acOutputTable, "TableName", acFormatXLS, strTemp, 1
  11.  
  12. 'Save the workbook
  13. Dim strSavePath As String
  14. Dim strFileNm As String
  15. strSavePath = "C:\Database\Example.xls"
  16.  
  17. xlApp.ActiveWorkbook.SaveAs strSavePath
  18.  
  19. 'Close Excel
  20. xlApp.Quit
  21. Set xlApp = Nothing
  22.  
  23.  
  24. End Function
Feb 21 '08 #3
ramdil
46
Hi

Thanks for reply..what is the object xlApp refered,is it excel object



Function test()
Dim db As dao.Database
Set db = CurrentDb

Dim strTemp As String

strTemp = "C:\Database\test.csv"


DoCmd.OutputTo acOutputTable, "TableName", acFormatXLS, strTemp, 1

'Save the workbook
Dim strSavePath As String
Dim strFileNm As String
strSavePath = "C:\Database\Example.xls"

xlApp.ActiveWorkbook.SaveAs strSavePath

'Close Excel
xlApp.Quit
Set xlApp = Nothing


End Function
Feb 22 '08 #4
NeoPa
32,556 Expert Mod 16PB
It's the Excel application.
After a closer look though, it may need some extra code to set it up before use. Check out Application Automation for what you may need to add for this to work.
Feb 22 '08 #5
NeoPa
32,556 Expert Mod 16PB
Function test()
Dim db As dao.Database
Set db = CurrentDb
...
'Close Excel
xlApp.Quit
Set xlApp = Nothing

End Function
Cori, I've noticed a number of your helpful responses in the forum, so I don't want to sound critical.
Please remember to use the [ CODE ] tags in future when including code in your posts. I've updated this one for you.

Welcome to TheScripts & keep up the good work :)
Feb 22 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: DarkSpy | last post by:
many c++ compilers including "gcc" have not implemented the "export" keyword, but the comeau compilers made it (just i knew). i want to know about: is it too difficult to implement "export"...
0
by: Shawn Mehaffie | last post by:
I have the following class that I've wirtten to take a Dataset and automatically export it to either XML, ASCII or Tab delimited file. The reason I wrote it they way I did was that I don't want to...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
6
by: maricel | last post by:
Is there anybody out there who have any idea why EXPORT is relatively slower when putting the output file on a network drive - map drive from onother PC compared to putting it on my local PC drive...
5
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after...
0
by: Shawn Mehaffie | last post by:
I have the following class that I've wirtten to take a Dataset and automatically export it to either XML, ASCII or Tab delimited file. The reason I wrote it they way I did was that I don't want to...
1
by: chaitu | last post by:
Hi, Can anybody tell me what the error code for Export is. Like i get the message SQL3104N The Export utility is beginning to export data to file...
4
by: Steven T. Hatton | last post by:
<quote url="http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=53&rl=1"> exported Templates Last updated Sep 6, 2006. exported Templates The separate compilation model enables...
9
by: NEWSGROUPS | last post by:
I have data in a table in an Access 2000 database that needs to be exported to a formatted text file. For instance, the first field is an account number that is formatted in the table as text and...
8
by: iheartvba | last post by:
Hi I am using Access 2007 and am trying to export a query to a fixed length text file. I tried using the following code to export the text file: DoCmd.TransferText acExportFixed, , "qryFFRDeFile",...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.