• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

export string to csv file

I have a string I would like to export to a csv file but am not sure what I am doing wrong. I think it may be in the DoCmd.TransferText.

Any ideas?
Dim rs

Set qd = CurrentDb.QueryDefs("qryInvoice_1ToExportToAccountingInsert")
For cnt = 0 To qd.Parameters.Count - 1
   qd.Parameters(cnt) = Eval(qd.Parameters(cnt).Name)
Next cnt

Set rs = qd.OpenRecordset()

Do While Not rs.EOF

'Amount including tax
sSql = "411000," & rs!ClientCodeID & ",0," & rs!TotalIncludingTax & "," & rs!InvoiceDate & _
",VT," & rs!InvoiceCompanyName & "," & rs!InvoiceNumber & vbCrLf

'Amount excluding tax
sSql = sSql & "706100,," & rs!TotalExcludingTax & ",0," & rs!InvoiceDate & _
",VT," & rs!InvoiceCompanyName & "," & rs!InvoiceNumber & vbCrLf

'tax
If rs!TotalTax <> 0 Then
sSql = sSql & "445713000,," & rs!TotalTax & ",0," & rs!InvoiceDate & _
",VT," & rs!InvoiceCompanyName & "," & rs!InvoiceNumber & vbCrLf
End If

'rs.Edit
'rs("DateExportedToAccounting") = date
'rs.Update
   
        'go to next recotd
        rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing

DoCmd.TransferText acExportDelim, "", sSql, "H:\import\results.csv", False, ""

Open in new window

0
Shawn
Asked:
Shawn
  • 2
1 Solution
 
ShawnAuthor Commented:
found answer at utter access. one of the first times it actually beat ee.

solution:
Dim hFile As Integer
Dim strFilename As String

strFilename = "YourPathAndFilename.csv"

hFile = FreeFile


Open strFilename For Output As #hFile

Print #hFile, strYourTextContent

Close #hFile

0
 
ShawnAuthor Commented:
solution found
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now