Create CSV from a query with VBA

  • Thread starter Thread starter dzjoepke
  • Start date Start date
D

dzjoepke

Guest
Any help on this would be much appreciated (At this moment, I'm pulling out my hairs... :o) : I would like to export a query by Access VBA and save this file in csv (command seperated value) - format.

I work with Ms Access2000 and my tables are stored in postgreSQL.

I (try to) do this with the following code :

Dim anaam As String
Dim querynaam As String

querynaam = "Q-Selectiequery_email"
anaam = "c:\temp\test"
DoCmd.TransferText acExportDelim, , querynaam, anaam

But I always get this error :
"Cannot change the data. The database or the object is read-only"

I verified that there is no file named c:\temp\test .

My query that I want to export in CSV looks like this (Q-Selectiequery_email) :

SELECT [Q-selectiequery].FNaam, [Q-selectiequery].Voornaam, [Q-selectiequery].Email
FROM [Q-selectiequery];


Can someone give me a hand on this?
Maybe there is another way to automatically create a csv-file from a query?

Thanks!
Joepie.
 
Last edited:
Try adding a file extension to the file name:-

anaam = "c:\temp\test.txt"
.
 

Users who are viewing this thread

Back
Top Bottom