Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #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

Reply With Quote
  #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
Reply With Quote
  #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


Reply With Quote
  #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
Reply With Quote
  #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

Reply With Quote
  #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
Reply With Quote
  #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.

Reply With Quote
  #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

Reply With Quote
  #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
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 07: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



All times are GMT -4. The time now is 06:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.