Unanswered: how to make header and footer on export to text file?
Hi to All
If sameone cant help me with exporting form to text file.
I make module :
Private Sub cmbExport_Click()
Dim db As Database, rst As Recordset, SQL As String
Dim a As Integer, OrderNo, Vessel, AccCode, RDate, Cost, Myfile As String
Set db = CurrentDb
Myfile = "C:\_Nikola\test.txt"
SQL = "SELECT Order.OrderNo, AccCode.Code, Vessel.VesselCode, Order.Date, Order.EstCostUSD" & _
" FROM Vessel INNER JOIN (AccCode INNER JOIN [Order] ON AccCode.AccCodeID = Order.AccCodeID) ON Vessel.VesselID = Order.VesselID" & _
" WHERE (((Order.EstCostUSD) Is Not Null))" & _
" ORDER BY Vessel.VesselCode"
Set rst = db.OpenRecordset(SQL)
Open Myfile For Output As #1
****For a = 1 To rst.RecordCount
****OrderNo = Trim(rst!OrderNo) & Space(25 - Len(Trim(rst!OrderNo)))
****AccCode = Trim(rst!Code) & Space(8 - Len(Trim(rst!Code)))
****Vessel = Trim(rst!VesselCode) & Space(5 - Len(Trim(rst!VesselCode)))
****RDate = Trim(rst!Date) & Space(10 - Len(Trim(rst!Date)))
****Cost = Trim(rst!EstCostUSD) & Space(15 - Len(Trim(rst!EstCostUSD)))
****Print #1, OrderNo & Vessel & RDate & Cost
and is work OK but i nead to things:
1.how to make header and footer on text file?
in header i nead to have 5 field:
field 1 = Always DFM
field 2 = Always ACR
field 3 = if i make report for January in February then is 01/02
field 4 = Always IMPORT + 3 space at end
field 5 = Always $$$
so header nead to look like this:
DFM ACR 01/02 IMPORT $$$
in footer nead to be just
2.Text file what i have is give me list of all Vessel what is ok if is posible
for each vessel to be separated by header and footer or how to make
text file with header and footer for one vessel?
PracticalProgram Thanks for replies,
but i have problem in body of my export to
i make query and for field Vessel put criteria [Enter Vessel Name].What is working ok but when i try to export this query to text file is give me error : to many parameter.
and if i erase criteria ,export is working OK but now is give me all vessel and all record in this one text file???
So how to split to show me:
Header- DFM ACR 02/02 IMPORT $$$
Body - all record for first vessel
Footer - ************
Header - DFM ACR 02/02 IMPORT $$$
body - all record for second vessel
Footer - ************
and ect.. ect
or if is easy
how first to select vessel and then make
export to text file?