Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    17

    Unanswered: Import text file

    I have made a VBA code where I import multiple text files. I have made 4 identical import specification name, The code is:

    Private Sub Command0_Click()

    Dim stfilbane As String

    Application.FileDialog(msoFileDialogOpen).Filters. Clear
    Application.FileDialog(msoFileDialogOpen).Filters. Add "Textfile", "*.txt"

    If Application.FileDialog(msoFileDialogOpen).Show = -1 Then
    strfilbane = Application.FileDialog(msoFileDialogOpen).Selected Items(1)
    DoCmd.TransferText acImportDelim, "Tray1", "tbl_ImportMatrix", strfilbane, False, ""
    strfilbane = Application.FileDialog(msoFileDialogOpen).Selected Items(2)
    DoCmd.TransferText acImportDelim, "Tray2", "tbl_ImportMatrix", strfilbane, False, ""
    strfilbane = Application.FileDialog(msoFileDialogOpen).Selected Items(3)
    DoCmd.TransferText acImportDelim, "Tray3", "tbl_ImportMatrix", strfilbane, False, ""
    strfilbane = Application.FileDialog(msoFileDialogOpen).Selected Items(4)
    End If

    End Sub

    When I'm finished the table looks like showed pic1, but I want it to look like pic2. How can I do that?

    Geir Arne
    Attached Thumbnails Attached Thumbnails Picture1.bmp   picture2.bmp  

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can run secondary queries that will reorganise the table. Personally I would import into a temporary table from which I would call a query to transfer the imported data to the proper columns of the table tbl_ImportMatrix.
    Have a nice day!

  3. #3
    Join Date
    May 2011
    Posts
    17

    Import text file

    I have created a temporary table and I have tried to create append, update, Union and make-table query without result. What am I doing wrong?

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Without knowing what you tried, I can't say what you did wrong. I would be easier to help you if you could post the SQL statements of the queries.
    Have a nice day!

Posting Permissions

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