Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Location
    Turkey
    Posts
    6

    Unanswered: import text files loop vba..

    hello ..
    I want to import my text files, more than 200 to my database.
    I have tablenames, import_specification and file names in a query ...
    how can I do ?
    thanks .




    Private Sub Command62_Click()
    Dim db As Database
    Dim rst As Recordset
    Dim data_islemleri As QueryDef
    Set db = CurrentDb


    Dim table_name As String
    Dim file_name As String
    Set rst = data_islemleri
    With rst

    Do While Not rst.EOF
    DoCmd.TransferText acImportDelim, "table_name", "table_name", "d:\belgelerim\subedb.exp\file_name"
    Loop
    End With

    End Sub

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    You've got most of it there, but let's simplify:

    Code:
    Dim rst As Recordset
    
    Set rst = currentdb().openrecordset("data_islemleri")
    
    Do Until.EOF
         DoCmd.TransferText acImportDelim, rst("SourceTableName"), rst("DestinationTableName"), rst("FullPathToFile")
    Loop
    
    rst.close
    Set rst=Nothing
    data_islemleri should be a table, or query, from which you can pull those three fields.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

Posting Permissions

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