|
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
|
|
|
May 22nd, 2006, 02:53 AM
|
Authorized User
|
|
Join Date: May 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
May 22nd, 2006, 07:34 AM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
You need to specify a path to the file.
DoCmd.TransferText acExportDelim, "Addresses", "C:\thecsvfile.csv",True
HTH
mmcdonal
|
May 31st, 2006, 08:31 AM
|
Authorized User
|
|
Join Date: May 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
May 31st, 2006, 08:41 AM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
May 31st, 2006, 08:44 AM
|
Authorized User
|
|
Join Date: May 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
May 31st, 2006, 08:52 AM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Please note the exact syntax here:
DoCmd.TransferText acExportDelim, , "tblTableOrQueryName", "C:\FileName.csv"
mmcdonal
|
May 31st, 2006, 10:08 AM
|
Authorized User
|
|
Join Date: May 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That worked a treat, thank you.
|
June 1st, 2006, 05:04 AM
|
Authorized User
|
|
Join Date: May 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
June 1st, 2006, 08:47 AM
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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
|
June 2nd, 2006, 06:28 AM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
|
|