Output of a Report To .csv format

paulS30berks

Registered User.
Local time
Today, 17:30
Joined
Jul 19, 2005
Messages
116
I have a report and wish to convert the output of this report into a .csv file.

Can anyone help?

Thanks

Paul
 
You need to export the underlying data rather than the report itself if you want it in CSV format.
HTH

Peter
 
Thanks for your reply

Its the data that I need. I am sure there is a macro or VBA code I can use?

Can anyone help?

Thanks
 
I have created a button on a form that I hope will export the output to a csv file. The underlying VBA within the Event procedure I am using is:

Private Sub Form_Click()
Option Compare Database
Private Sub export_Click()
On Error GoTo Err_export_Click
Dim AString As String
AString = "Export_Occupancy_"
DoCmd.TransferText acExportDelim, "", "ChildCare Vouchers For Accor", "\\uk.michaelpage.local\dfs\holdingsdata\nsac\Management Accounts\Paul Spencer" & AString & Format(date, "YYYY_MMDD") & Format(Time, "-HH_MM") & ".csv"
Exit_export_Click:
Exit Sub
Err_export_Click:
MsgBox Err.Description
Resume Exit_export_Click
End Sub

End Sub

ChildCare Vouchers For Accor - being the report I have selected from the Form.

Once I click the "Output To CSV" button on the form nothing seems to happen - output csv file to that directory.

Does anyone have any suggestions on what I may be doing wrong?

Thanks
 
Unless it is just the way you have posted it you have embedded the code inside another sub!
Private Sub Form_Click()
Option Compare Database

Private Sub export_Click()
On Error GoTo Err_export_Click
Dim AString As String
AString = "Export_Occupancy_"
DoCmd.TransferText acExportDelim, "", "ChildCare Vouchers For Accor", "\\uk.michaelpage.local\dfs\holdingsdata\nsac\Management Accounts\Paul Spencer" & AString & Format(date, "YYYY_MMDD") & Format(Time, "-HH_MM") & ".csv"
Exit_export_Click:
Exit Sub
Err_export_Click:
MsgBox Err.Description
Resume Exit_export_Click
End Sub


End Sub


Get rid of the bold bits and see what happens.
I would also try using a nice short path to test it with as well
C:/MyTestFile.csv"

Peter
 
Last edited:
I have run this command from the form i.e have set up a button to output to a csv file and written the code as an Event procedure.

On click the code seems to work, but no output to that directory. There is data in the query.

Thanks
 
Your command which exports

DoCmd.TransferText acExportDelim, "", "ChildCare Vouchers For Accor", "\\uk.michaelpage.local\dfs\holdingsdata\nsac\Management Accounts\Paul Spencer" & AString & Format(date, "YYYY_MMDD") & Format(Time, "-HH_MM") & ".csv"


Include a name for ".csv"

Should be "C:\Folder\output.csv" as an example.....

Try it.

Good Luck
 
Did you remove the extra code?
On click the code seems to work
What makes you think it works? no error message may mean the code is not running at all!
try putting in a message box to check
Dim AString As String
msgBox "Codes Running"
AString = "Export_Occupancy_"

Did you try the short path/name to make sure the error is not there?

Peter
 
Apologies just a quick question.

No Field names have been printed. How can I include these within the .csv file?

thanks
 

Users who are viewing this thread

Back
Top Bottom