Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 22nd, 2006, 02:53 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export To .csv File

I wondered if someone could help me.

I have set up the following code to export results from query "addresses" to a .csv file, but receive a Compile Error.

Private Sub Command6_Click()

DoCmd.TransferText acExportDelim, "Addresses",
"thecsvfile.csv",True

End Sub

  #2 (permalink)  
Old May 22nd, 2006, 07:34 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You need to specify a path to the file.

DoCmd.TransferText acExportDelim, "Addresses", "C:\thecsvfile.csv",True

HTH



mmcdonal
  #3 (permalink)  
Old May 31st, 2006, 08:31 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there. I have tried this code and it gives me a debug error stating that ... the test file "marketing" does not exist, This is the query i want it to run, would i need to create a text file?


DoCmd.TransferText acExportDelim, "Marketing", "C:\Act.csv",True

Can anyone shed some light on this, as it doesnt seem to run the query i have made :(

Thanks


  #4 (permalink)  
Old May 31st, 2006, 08:41 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I think the error you are getting is that the database can't find the object "Marketing". Is there a query or table with this name in the database?


mmcdonal
  #5 (permalink)  
Old May 31st, 2006, 08:44 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I changed "Marketing" to "Act Query" which represents a query that i have made within the database. It still comes back with the same error. Even though the query is working?

Allan

  #6 (permalink)  
Old May 31st, 2006, 08:52 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Please note the exact syntax here:

DoCmd.TransferText acExportDelim, , "tblTableOrQueryName", "C:\FileName.csv"

mmcdonal
  #7 (permalink)  
Old May 31st, 2006, 10:08 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked a treat, thank you.

  #8 (permalink)  
Old June 1st, 2006, 05:04 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have it working so that when you check a check field it sends it to the csv, is there any way i can reset the check field after sending?

Thanks

  #9 (permalink)  
Old June 1st, 2006, 08:47 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You could run a query that will do this... Either calling a saved query, or running some SQL from VBA - "UPDATE myTableName SET checkBoxColumn = 0"

Mike

Mike
EchoVue.com
  #10 (permalink)  
Old June 2nd, 2006, 06:28 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

If the form is not closed, you could probably also reset the check box by setting the value to 0.

I would be careful since the user may check the box, then watch it unchceck, and then keep trying to check it again and again. Why not put this on a button on click event. Also, you could have a message box pop up to tell the user the file has been created successfully (If err = 0).



mmcdonal




Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet export to .csv file snufse1 ASP.NET 2.0 Basics 3 September 22nd, 2008 07:22 AM
Export to Excel as .csv file from JSP naheedv Reporting Services 3 November 30th, 2006 08:04 AM
index lost when export to csv file chacquard Access VBA 1 October 10th, 2006 01:57 PM
How To Export a specific Excel Sheet as a csv file mrjits Excel VBA 5 August 1st, 2006 03:04 PM
Export data in to csv file from asp.netpage madhusrp ASP.NET 1.0 and 1.1 Professional 1 June 9th, 2006 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.