S
SEAN DI''''ANNO
Good afternoon, Using code snippets I have found, I have managed to create a
nice filter on a form. I am now trying to export the results of the query to
a csv file. The code below works fine except, I don't know how to write the
manual header to the csv file.
I currently have
'Create and write the header line
StrHeader = Chr(34) & "," & Chr(34)
StrHeader = Chr(34) & " Group No" & Chr(9) & "Group Name" & Chr(34)
At the moment, I just have Group No Group Name appearing in the first line
but all in the first column. Can some one please help?
This is all the code I am using
Dim dbsNorthwind As DAO.Database
Dim rstRecords As DAO.Recordset
Dim StrHeader As String
Set dbsNorthwind = CurrentDb
Set rstRecords = dbsNorthwind.OpenRecordset("SELECT
Qry_Corporate_Accounts.* FROM Qry_Corporate_Accounts " & BuildFilter)
Open "C:\SEAN.CSV" For Output As #1
'Create and write the header line
StrHeader = Chr(34) & "," & Chr(34)
StrHeader = Chr(34) & " Group No" & Chr(9) & "Group Name" & Chr(34)
Print #1, StrHeader
Do While Not rstRecords.EOF
Write #1, rstRecords![Group No], rstRecords![Corporate Name]
rstRecords.MoveNext
Loop
rstRecords.Close
dbsNorthwind.Close
Set rstRecords = Nothing
Set dbsNorthwind = Nothing
Close #1
nice filter on a form. I am now trying to export the results of the query to
a csv file. The code below works fine except, I don't know how to write the
manual header to the csv file.
I currently have
'Create and write the header line
StrHeader = Chr(34) & "," & Chr(34)
StrHeader = Chr(34) & " Group No" & Chr(9) & "Group Name" & Chr(34)
At the moment, I just have Group No Group Name appearing in the first line
but all in the first column. Can some one please help?
This is all the code I am using
Dim dbsNorthwind As DAO.Database
Dim rstRecords As DAO.Recordset
Dim StrHeader As String
Set dbsNorthwind = CurrentDb
Set rstRecords = dbsNorthwind.OpenRecordset("SELECT
Qry_Corporate_Accounts.* FROM Qry_Corporate_Accounts " & BuildFilter)
Open "C:\SEAN.CSV" For Output As #1
'Create and write the header line
StrHeader = Chr(34) & "," & Chr(34)
StrHeader = Chr(34) & " Group No" & Chr(9) & "Group Name" & Chr(34)
Print #1, StrHeader
Do While Not rstRecords.EOF
Write #1, rstRecords![Group No], rstRecords![Corporate Name]
rstRecords.MoveNext
Loop
rstRecords.Close
dbsNorthwind.Close
Set rstRecords = Nothing
Set dbsNorthwind = Nothing
Close #1