Thanks removing the "Server" did indeed cause it to work.
Now I could use some help with getting it to output some data that I am generating instead of the hand coded
'Display the contents of the text file
objTextStream.WriteLine "Hello, World!"
objTextStream.WriteLine "This is fun!!"
Here is a sample fo the code that generates the data I want
Code:
Dim rs As DAO.Recordset
Dim objFile As Object, TextFile As Object
Dim TextRecord As NameofRecord6
'Set rs = CurrentDb.OpenRecordset("q_Export500ByteForClientManual")
Set rs = CurrentDb.OpenRecordset("q_Export500ByteRecord6")
Set objFile = CreateObject("Scripting.FileSystemObject")
Set TextFile = objFile.CreateTextFile("E:\A_500byte\export6.txt", True)
Do Until rs.EOF
With TextRecord
.VarRecordFormat = Nz(rs![RecordFormat], "")
.VarBillingInvoicingParty = Nz(rs![BillingInvoicingParty], "")
I tried working it in like this but it didnt work. I commented out the existing code. Basically, I was hoping it would still run the loop but instead of writing it out to the text file E:\A_500byte\export6.txt it would append it to the file E:\A_500byte\export.txt
Code:
Const fsoForAppend = 8Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("E:\A_500byte\export.txt", fsoForAppend)
'Dim rs As DAO.Recordset
'Dim objFile As Object, TextFile As Object
Dim TextRecord As NameofRecord6
'Set rs = CurrentDb.OpenRecordset("q_Export500ByteForClientManual")
'Set rs = CurrentDb.OpenRecordset("q_Export500ByteRecord6")
'Set objFile = CreateObject("Scripting.FileSystemObject")
'Set TextFile = objFile.CreateTextFile("E:\A_500byte\export6.txt", True)
Do Until rs.EOF
With TextRecord
.VarRecordFormat = Nz(rs![RecordFormat], "")
.VarBillingInvoicingParty = Nz(rs![BillingInvoicingParty], "")
.VarBilledParty = Nz(rs![BilledParty], "")
.VarAccountDate = Nz(rs![AccountDate], "")
.VarInvoiceNumber = Nz(rs![InvoiceNumber], "")
.VarPriceMasterCurrencyIndicator = Nz(rs![PriceMasterCurrencyIndicator], "")
.VarContactType = Nz(rs![ContactType], "")
.VarCompanyName = Nz(rs![CompanyName], "")
.VarContactName = Nz(rs![ContactName], "")
.VarContactTitle = Nz(rs![ContactTitle], "")
.VarContactPhone = Nz(rs![ContactPhone], "")
.VarContactFax = Nz(rs![ContactFax], "")
.VarContactEmail = Nz(rs![ContactEmail], "")
.VarContactAddress = Nz(rs![ContactAddress], "")
.VarContactAddress2 = Nz(rs![ContactAddress2], "")
.VarContactAddress3 = Nz(rs![ContactAddress3], "")
.VarContactAddress4 = Nz(rs![ContactAddress4], "")
.VarContactCity = Nz(rs![ContactCity], "")
.VarContactState = Nz(rs![ContactState], "")
.VarContactCountryCode = Nz(rs![ContactCountryCode], "")
.VarZipCode = Nz(rs![ZipCode], "")
.VarReserved = Nz(rs![Reserved], "")
TextFile.WriteLine (.VarRecordFormat & .VarBillingInvoicingParty & .VarBilledParty & .VarAccountDate & .VarInvoiceNumber & _
.VarPriceMasterCurrencyIndicator & .VarContactType & .VarCompanyName & .VarContactName & .VarContactTitle & .VarContactPhone & .VarContactFax & _
.VarContactEmail & .VarContactAddress & .VarContactAddress2 & .VarContactAddress3 & .VarContactAddress4 & .VarContactCity & _
.VarContactState & .VarContactCountryCode & .VarZipCode & .VarReserved)
End With
rs.MoveNext
Loop
'rs.Close
'TextFile.Close
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
End Sub