Two TransferText Problems

susor

Registered User.
Local time
Today, 00:32
Joined
Jul 10, 2003
Messages
14
I am trying to output a set of two files for faxing into Lightning Fax software. The first one (report) is coming out just fine. However, the second one (fax data header) is giving me fits.

Two problems:

(1) On its first pass, it creates the record in the "Header_Master" table OK but when it tries to write the .txt file, it results in a blank file. If I leave the record in the "Header_Master" table and run it again, it creates the .txt file OK, but now I have two identical records in "Header_Master" (my idea is to delete that temorary record after a fax is sent each time, but I haven't gotten to that yet).

(2) I'm getting commas where I don't want them. There has to be a way of outputting this text to a .txt file with only vbCrLf's but I can't figure out how to do it.

Here is the vb code, and how the data is SUPPOSED to look is down below:

Dim stDocName As String

stDocName = "Fax Macro"
DoCmd.RunMacro stDocName

' Setup Recordset for Report_Counter
Dim cn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim f1 As ADODB.Field

' Setup Recordset for Header_Counter
Dim cn2 As New ADODB.Connection
Dim rs2 As New ADODB.Recordset
Dim f2 As ADODB.Field

' Setup Recordset for Fax_Master
Dim cn3 As New ADODB.Connection
Dim rs3 As New ADODB.Recordset
Dim f3 As ADODB.Field

' Setup Recordset for Header_Master
Dim cn4 As New ADODB.Connection
Dim rs4 As New ADODB.Recordset
Dim f4 As ADODB.Field

' Open the connection for Report_Counter
cn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:/FAX/FAX.mdb;"

' Open the connection for Header_Counter
cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:/FAX/FAX.mdb;"

' Open the connection for Fax_Master
cn3.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:/FAX/FAX.mdb;"

' Open the connection for Header_Master
cn4.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:/FAX/FAX.mdb;"

' Open the forward-only,
' read-only recordset for Report_Counter
rs1.Open "SELECT * FROM Report_Counter", cn1, adOpenForwardOnly, adLockReadOnly
rs1.MoveFirst

' Open the forward-only,
' read-only recordset for Header_Counter
rs2.Open "SELECT * FROM Header_Counter", cn2, adOpenForwardOnly, adLockReadOnly
rs2.MoveFirst

' Open the recordset for Fax_Master
rs3.Open "Fax_Master", cn3, adOpenKeyset, adLockOptimistic

' Open the recordset for Header_Master
rs4.Open "Header_Master", cn4, adOpenKeyset, adLockOptimistic

' Write the report out to the .doc fax file in .rtf format
Dim stReportFileName As String
stReportFileName = "C:/Scott/Fax" & rs1.Fields("NextReportNo").Value & ".doc"
DoCmd.OutputTo acReport, "Fax Report", "RichTextFormat(*.rtf)", stReportFileName

' Find the first Fax_Master record whose Clear (Flag) is null
rs3.Find "Clear=null"

' Add a new Header_Master record
rs4.AddNew
rs4!UserID = "@USER_ID Criminal" & vbCrLf
rs4!UserPassword = "@USER_PASSWORD 1234567" & vbCrLf
rs4!FaxNumber = "@FAX_NUMBER " & rs3.Fields("VendorFaxNumber").Value & vbCrLf
rs4!ConversionFile = "@CONVERSION_FILE " & "C:/Scott/Fax" & rs1.Fields("NextReportNo").Value & ".doc" & vbCrLf
rs4!ConversionMode = "@CONVERSION_MODE LFEngine" & vbCrLf
rs4!Company = "@COMPANY " & rs3.Fields("VendorName").Value & vbCrLf
rs4!End = "@END" & vbCrLf
rs4.Update

' Write the header out to the .txt fax file
Dim stHeaderFileName As String
stHeaderFileName = "C:/Scott/Fax" & rs2.Fields("NextHeaderNo").Value & ".txt"
DoCmd.TransferText acExportDelim, , "Header_Master", stHeaderFileName

' Dim stHeaderFileName As String
' stHeaderFileName = "C:/Scott/Fax" & rs2.Fields("NextHeaderNo").Value & ".txt"
' DoCmd.OutputTo acReport, "Fax Header", acFormatTXT, stHeaderFileName

' Delete Header_Master
' DoCmd.OpenQuery "Delete Header_Master"

' Close the recordsets
rs1.Close
rs2.Close
rs3.Close
rs4.Close

++++++++++++++
This is how the fax header is supposed to look:

@USER_ID Criminal
@USER_PASSWORD 1234567
@FAX_NUMBER 111-222-3333
@CONVERSION_FILE C:/Scott/Fax1.doc
@CONVERSION_MODE LFEngine
@COMPANY AAA
@END

+++++++++++++++

Can anybody help me figure this out? Thanks!

Scott
 

Users who are viewing this thread

Back
Top Bottom