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)
rst.MoveLast
rst.MoveFirst
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
rst.MoveNext
Next
Close #1
rst.Close
db.Close
End Sub
and is work OK but i nead to things:
1.how to make header and footer on text file?
2.how to make text file to be for all Vessel or for only 1 vessel
Thanks
Fule Fule
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)
rst.MoveLast
rst.MoveFirst
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
rst.MoveNext
Next
Close #1
rst.Close
db.Close
End Sub
and is work OK but i nead to things:
1.how to make header and footer on text file?
2.how to make text file to be for all Vessel or for only 1 vessel
Thanks
Fule Fule