Results 1 to 3 of 3
  1. #1
    marubal21 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    2

    Smile Missing records when importing

    Hi,
    I have a module I use to import multiple text files at once, it works fine and I got it doing what I needed. The problem is that every time I import a file it misses the 1st record in that text file, any ideas?

    This is the code I'm currently using for importing:

    Public Sub subImport()
    On Error GoTo Err_subImport

    Dim stDocName As String
    Dim fs As FileSearch
    Dim ifn As String
    Dim sql As String
    Dim today As String
    Dim fso As Scripting.FileSystemObject
    Dim oktogo As Boolean
    Dim specname As String
    Dim repdate As String
    Dim myfile As Scripting.TextStream
    Dim i As Long
    Dim y As Integer
    Dim ShortFn As String

    specname = "Import Specs"

    DoCmd.SetWarnings False
    oktogo = False
    ifn = CurrentProject.Path & "\Imports\"
    Set fs = Application.FileSearch
    With fs
    .LookIn = ifn

    .FileName = "*.txt"
    If .Execute(SortBy:=msoSortByFileName, _
    SortOrder:=msoSortOrderAscending) > 0 Then

    For i = 1 To .FoundFiles.Count

    ShortFn = Right(.FoundFiles(i), Len(.FoundFiles(i)) - InStrRev(.FoundFiles(i), "\"))
    DoCmd.TransferText acImportFixed, specname, "tbl_temp_Import", .FoundFiles(i), True
    y = y + 1

    Next i
    Else
    MsgBox "Please ensure that the source file is present and try again" & vbCr _
    & "Required file location: " & vbCr & ifn, vbExclamation + vbOKOnly, "Input File Missing"

    Exit Sub
    End If
    End With



    MsgBox "Import complete. " & y & " files Imported", vbOKOnly + vbInformation, "Import Complete"

    Exit_subImport:
    ' Turn warning messages back on
    DoCmd.SetWarnings True

    Exit Sub

    Err_subImport:
    MsgBox Err.Description
    Resume Exit_subImport

    End Sub

  2. #2
    dsmacs is offline Advanced Beginner
    Windows XP Access 2010 (version 14.0)
    Join Date
    Oct 2009
    Location
    Perth Western Australia
    Posts
    52
    In the DoCmd.TransferText line you have True at the end which tells the top line is field names. Change this to false and it will import.

    Cheers
    Darren

  3. #3
    ldappa is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    6
    how do you use this module??? Im still not clear on how to use modules unless there are specific directions in the code.

    Please help
    Ldappa

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 04-27-2010, 01:00 PM
  2. Probably missing something easy
    By z1efuller1 in forum Database Design
    Replies: 5
    Last Post: 11-12-2009, 11:18 AM
  3. Find Missing Records
    By Flanders in forum Queries
    Replies: 6
    Last Post: 06-24-2009, 07:02 AM
  4. Missing Operator error
    By data123 in forum Forms
    Replies: 1
    Last Post: 03-15-2009, 04:34 PM
  5. Microsoft Access 2003-Missing Records??
    By kristenlee in forum Access
    Replies: 1
    Last Post: 04-04-2008, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums