Link to home
Start Free TrialLog in
Avatar of Shawn
ShawnFlag for Canada

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Shawn
Shawn
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shawn

ASKER

solution found