Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002

    Unhappy 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
    ****Close #1
    End Sub
    and is work OK but i nead to things: 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?

  2. #2
    Join Date
    Sep 2001
    Chicago, Illinois, USA

    It looks like you've already done the hardest part!

    Did you just inherit this code, and don't understand it, which is why you are asking about this?

    The reason I ask is that, if you wrote this code, then it certainly should be no problem to do what your asking.

    Basically, for the header, after the OPEN MyFile . . .

    . . . you're going to add a line like this:

    Print #1, "DFM ACR " & format$("mm/yy",Date()) & " IMPORT $$$"

    You're going to have to come up with some methodolgy to control the input date to that format function. As I have written it, it uses the current date.

    Basically, for the footer, after the NEXT . . .

    . . . you're going to add two lines like this:

    Print #1, "**********"
    Print #1, "$$$$$$$$$$"

    If you want to create a header and footer record, you're going to have to track when a change occurs in the vessel number and, at that time, print the footer and header lines.

  3. #3
    Join Date
    Feb 2002
    PracticalProgram Thanks for replies,
    but i have problem in body of my export to
    text file.
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts